-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcommon.h
144 lines (113 loc) · 3.59 KB
/
common.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (C) 2015-2018 Anton Burdinuk
* http://xupnpd.org
*/
#ifndef __COMMON_H
#define __COMMON_H
#include "compat.h"
#include <string>
#include <map>
#include <stdarg.h>
#include <time.h>
#include <stdio.h>
#ifndef _WIN32
#define log(FMT,ARGS...) utils::trace(utils::log_debug,FMT,ARGS)
#else
#define log(FMT,...) utils::trace(utils::log_debug,FMT,__VA_ARGS__)
#endif /* _WIN32 */
namespace xupnpd
{
bool all_init_1(int argc,char** argv);
bool all_init(int argc,char** argv);
void all_done_1(void);
void all_done(void);
}
namespace cfg
{
extern std::string ssdp_interface;
extern int ssdp_broadcast_delay;
extern int ssdp_max_age;
extern std::string ssdp_group_address;
extern int ssdp_group_port;
extern std::string ssdp_server;
extern bool ssdp_loop;
extern int ssdp_ttl;
extern int http_port;
extern int http_rcv_timeout;
extern int http_snd_timeout;
extern int http_backlog;
extern int http_keep_alive_timeout;
extern int http_keep_alive_max;
extern int http_max_post_size;
extern std::string http_www_root;
extern std::string http_templates;
#ifndef NO_SSL
extern bool openssl_verify;
extern std::string openssl_ca_location;
#endif
extern int live_rcv_timeout;
extern int live_snd_timeout;
extern std::string upnp_device_name;
extern std::string upnp_device_uuid;
extern int upnp_sid_ttl;
extern int upnp_objid_offset;
extern std::string upnp_live_length;
extern std::string upnp_live_type;
extern std::string upnp_http_type;
extern std::string upnp_logo_profile;
extern bool upnp_hdr_content_disp;
extern int log_level;
extern bool disable_dlna_extras;
extern std::string db_file;
extern std::string media_root;
extern std::string io_charset;
extern std::string log_file;
extern std::string multicast_interface;
extern bool daemon_mode;
extern std::string http_proxy;
extern int startup_delay;
extern std::string www_location;
extern std::string http_addr;
extern std::string uuid;
extern int system_update_id;
extern std::string version;
extern std::string about;
#ifndef _WIN32
extern pid_t parent_pid;
#endif
}
namespace utils
{
enum
{
log_err = 1,
log_info = 2,
log_http = 3,
log_http_hdrs = 4,
log_soap = 5,
log_ssdp = 6,
log_core = 7,
log_debug = 8
};
bool init(void);
std::string trim(const std::string& s);
void rm_last_slash(std::string& s);
std::string uuid_gen(void);
const std::string& vformat(std::string& dst,const char* fmt,va_list ap);
const std::string& format(std::string& dst,const char* fmt,...);
std::string format(const char* fmt,...);
bool is_trace_needed(int level);
void trace(int level,const char* fmt,...);
extern FILE* trace_fp;
std::string sys_time(time_t timestamp);
bool read_template(const std::string& from,std::string& to);
u_int64_t get_file_length(const std::string& s);
std::string inet_ntoa(struct in_addr addr);
void do_scan_for_media(void);
void md5(const std::string& s,std::string& dst);
int base64encode(unsigned char* src,int nsrc,unsigned char* dst,int ndst);
bool is_template(const std::string& s);
bool openlog(void);
}
#endif