Remove pc directory
Andreas Moog
9 years ago
0 | # | |
1 | # This file if part of nzbget | |
2 | # | |
3 | # Copyright (C) 2008-2014 Andrey Prygunkov <hugbug@users.sourceforge.net> | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 2 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program; if not, write to the Free Software | |
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
18 | # | |
19 | # | |
20 | ||
21 | bin_PROGRAMS = nzbget | |
22 | ||
23 | nzbget_SOURCES = \ | |
24 | daemon/connect/Connection.cpp \ | |
25 | daemon/connect/Connection.h \ | |
26 | daemon/connect/TLS.cpp \ | |
27 | daemon/connect/TLS.h \ | |
28 | daemon/connect/WebDownloader.cpp \ | |
29 | daemon/connect/WebDownloader.h \ | |
30 | daemon/feed/FeedCoordinator.cpp \ | |
31 | daemon/feed/FeedCoordinator.h \ | |
32 | daemon/feed/FeedFile.cpp \ | |
33 | daemon/feed/FeedFile.h \ | |
34 | daemon/feed/FeedFilter.cpp \ | |
35 | daemon/feed/FeedFilter.h \ | |
36 | daemon/feed/FeedInfo.cpp \ | |
37 | daemon/feed/FeedInfo.h \ | |
38 | daemon/frontend/ColoredFrontend.cpp \ | |
39 | daemon/frontend/ColoredFrontend.h \ | |
40 | daemon/frontend/Frontend.cpp \ | |
41 | daemon/frontend/Frontend.h \ | |
42 | daemon/frontend/LoggableFrontend.cpp \ | |
43 | daemon/frontend/LoggableFrontend.h \ | |
44 | daemon/frontend/NCursesFrontend.cpp \ | |
45 | daemon/frontend/NCursesFrontend.h \ | |
46 | daemon/main/Maintenance.cpp \ | |
47 | daemon/main/Maintenance.h \ | |
48 | daemon/main/nzbget.cpp \ | |
49 | daemon/main/nzbget.h \ | |
50 | daemon/main/Options.cpp \ | |
51 | daemon/main/Options.h \ | |
52 | daemon/main/Scheduler.cpp \ | |
53 | daemon/main/Scheduler.h \ | |
54 | daemon/nntp/ArticleDownloader.cpp \ | |
55 | daemon/nntp/ArticleDownloader.h \ | |
56 | daemon/nntp/Decoder.cpp \ | |
57 | daemon/nntp/Decoder.h \ | |
58 | daemon/nntp/NewsServer.cpp \ | |
59 | daemon/nntp/NewsServer.h \ | |
60 | daemon/nntp/NNTPConnection.cpp \ | |
61 | daemon/nntp/NNTPConnection.h \ | |
62 | daemon/nntp/ServerPool.cpp \ | |
63 | daemon/nntp/ServerPool.h \ | |
64 | daemon/nntp/StatMeter.cpp \ | |
65 | daemon/nntp/StatMeter.h \ | |
66 | daemon/postprocess/ParChecker.cpp \ | |
67 | daemon/postprocess/ParChecker.h \ | |
68 | daemon/postprocess/ParCoordinator.cpp \ | |
69 | daemon/postprocess/ParCoordinator.h \ | |
70 | daemon/postprocess/ParRenamer.cpp \ | |
71 | daemon/postprocess/ParRenamer.h \ | |
72 | daemon/postprocess/PostScript.cpp \ | |
73 | daemon/postprocess/PostScript.h \ | |
74 | daemon/postprocess/PrePostProcessor.cpp \ | |
75 | daemon/postprocess/PrePostProcessor.h \ | |
76 | daemon/postprocess/Unpack.cpp \ | |
77 | daemon/postprocess/Unpack.h \ | |
78 | daemon/queue/DiskState.cpp \ | |
79 | daemon/queue/DiskState.h \ | |
80 | daemon/queue/DownloadInfo.cpp \ | |
81 | daemon/queue/DownloadInfo.h \ | |
82 | daemon/queue/DupeCoordinator.cpp \ | |
83 | daemon/queue/DupeCoordinator.h \ | |
84 | daemon/queue/HistoryCoordinator.cpp \ | |
85 | daemon/queue/HistoryCoordinator.h \ | |
86 | daemon/queue/NZBFile.cpp \ | |
87 | daemon/queue/NZBFile.h \ | |
88 | daemon/queue/QueueCoordinator.cpp \ | |
89 | daemon/queue/QueueCoordinator.h \ | |
90 | daemon/queue/QueueEditor.cpp \ | |
91 | daemon/queue/QueueEditor.h \ | |
92 | daemon/queue/QueueScript.cpp \ | |
93 | daemon/queue/QueueScript.h \ | |
94 | daemon/queue/Scanner.cpp \ | |
95 | daemon/queue/Scanner.h \ | |
96 | daemon/queue/UrlCoordinator.cpp \ | |
97 | daemon/queue/UrlCoordinator.h \ | |
98 | daemon/remote/BinRpc.cpp \ | |
99 | daemon/remote/BinRpc.h \ | |
100 | daemon/remote/MessageBase.h \ | |
101 | daemon/remote/RemoteClient.cpp \ | |
102 | daemon/remote/RemoteClient.h \ | |
103 | daemon/remote/RemoteServer.cpp \ | |
104 | daemon/remote/RemoteServer.h \ | |
105 | daemon/remote/WebServer.cpp \ | |
106 | daemon/remote/WebServer.h \ | |
107 | daemon/remote/XmlRpc.cpp \ | |
108 | daemon/remote/XmlRpc.h \ | |
109 | daemon/util/Log.cpp \ | |
110 | daemon/util/Log.h \ | |
111 | daemon/util/Observer.cpp \ | |
112 | daemon/util/Observer.h \ | |
113 | daemon/util/Script.cpp \ | |
114 | daemon/util/Script.h \ | |
115 | daemon/util/Thread.cpp \ | |
116 | daemon/util/Thread.h \ | |
117 | daemon/util/Util.cpp \ | |
118 | daemon/util/Util.h \ | |
119 | svn_version.cpp | |
120 | ||
121 | AM_CPPFLAGS = \ | |
122 | -I$(srcdir)/daemon/connect \ | |
123 | -I$(srcdir)/daemon/feed \ | |
124 | -I$(srcdir)/daemon/frontend \ | |
125 | -I$(srcdir)/daemon/main \ | |
126 | -I$(srcdir)/daemon/nntp \ | |
127 | -I$(srcdir)/daemon/postprocess \ | |
128 | -I$(srcdir)/daemon/queue \ | |
129 | -I$(srcdir)/daemon/remote \ | |
130 | -I$(srcdir)/daemon/util | |
131 | ||
132 | EXTRA_DIST = \ | |
133 | Makefile.cvs \ | |
134 | nzbgetd \ | |
135 | $(windows_FILES) \ | |
136 | $(osx_FILES) | |
137 | ||
138 | windows_FILES = \ | |
139 | daemon/windows/NTService.cpp \ | |
140 | daemon/windows/NTService.h \ | |
141 | daemon/windows/win32.h \ | |
142 | nzbget.sln \ | |
143 | nzbget.vcproj \ | |
144 | nzbget-shell.bat | |
145 | ||
146 | osx_FILES = \ | |
147 | osx/App_Prefix.pch \ | |
148 | osx/NZBGet-Info.plist \ | |
149 | osx/DaemonController.h \ | |
150 | osx/DaemonController.m \ | |
151 | osx/MainApp.h \ | |
152 | osx/MainApp.m \ | |
153 | osx/MainApp.xib \ | |
154 | osx/PFMoveApplication.h \ | |
155 | osx/PFMoveApplication.m \ | |
156 | osx/PreferencesDialog.h \ | |
157 | osx/PreferencesDialog.m \ | |
158 | osx/PreferencesDialog.xib \ | |
159 | osx/RPC.h \ | |
160 | osx/RPC.m \ | |
161 | osx/WebClient.h \ | |
162 | osx/WebClient.m \ | |
163 | osx/WelcomeDialog.h \ | |
164 | osx/WelcomeDialog.m \ | |
165 | osx/WelcomeDialog.xib \ | |
166 | osx/NZBGet.xcodeproj/project.pbxproj \ | |
167 | osx/Resources/Images/mainicon.icns \ | |
168 | osx/Resources/Images/statusicon.png \ | |
169 | osx/Resources/Images/statusicon@2x.png \ | |
170 | osx/Resources/Images/statusicon-inv.png \ | |
171 | osx/Resources/Images/statusicon-inv@2x.png \ | |
172 | osx/Resources/licenses/license-bootstrap.txt \ | |
173 | osx/Resources/licenses/license-jquery-GPL.txt \ | |
174 | osx/Resources/licenses/license-jquery-MIT.txt \ | |
175 | osx/Resources/Credits.rtf \ | |
176 | osx/Resources/Localizable.strings \ | |
177 | osx/Resources/Welcome.rtf | |
178 | ||
179 | doc_FILES = \ | |
180 | README \ | |
181 | ChangeLog \ | |
182 | COPYING | |
183 | ||
184 | exampleconf_FILES = \ | |
185 | nzbget.conf | |
186 | ||
187 | webui_FILES = \ | |
188 | webui/index.html \ | |
189 | webui/index.js \ | |
190 | webui/downloads.js \ | |
191 | webui/edit.js \ | |
192 | webui/fasttable.js \ | |
193 | webui/history.js \ | |
194 | webui/messages.js \ | |
195 | webui/status.js \ | |
196 | webui/style.css \ | |
197 | webui/upload.js \ | |
198 | webui/util.js \ | |
199 | webui/config.js \ | |
200 | webui/feed.js \ | |
201 | webui/lib/bootstrap.js \ | |
202 | webui/lib/bootstrap.min.js \ | |
203 | webui/lib/bootstrap.css \ | |
204 | webui/lib/jquery.js \ | |
205 | webui/lib/jquery.min.js \ | |
206 | webui/lib/raphael.js \ | |
207 | webui/lib/raphael.min.js \ | |
208 | webui/lib/elycharts.js \ | |
209 | webui/lib/elycharts.min.js \ | |
210 | webui/img/icons.png \ | |
211 | webui/img/icons-2x.png \ | |
212 | webui/img/transmit.gif \ | |
213 | webui/img/transmit-file.gif \ | |
214 | webui/img/favicon.ico \ | |
215 | webui/img/download-anim-green-2x.png \ | |
216 | webui/img/download-anim-orange-2x.png \ | |
217 | webui/img/transmit-reload-2x.gif | |
218 | ||
219 | scripts_FILES = \ | |
220 | scripts/EMail.py \ | |
221 | scripts/Logger.py | |
222 | ||
223 | # Install | |
224 | sbin_SCRIPTS = nzbgetd | |
225 | dist_doc_DATA = $(doc_FILES) | |
226 | exampleconfdir = $(datadir)/nzbget | |
227 | dist_exampleconf_DATA = $(exampleconf_FILES) | |
228 | webuidir = $(datadir)/nzbget | |
229 | nobase_dist_webui_DATA = $(webui_FILES) | |
230 | scriptsdir = $(datadir)/nzbget | |
231 | nobase_dist_scripts_SCRIPTS = $(scripts_FILES) | |
232 | ||
233 | # Note about "sed": | |
234 | # We need to make some changes in installed files. | |
235 | # On Linux "sed" has option "-i" for in-place-edit. Unfortunateley the BSD version of "sed" | |
236 | # has incompatible syntax. To solve the problem we perform in-place-edit in three steps: | |
237 | # 1) copy the original file to original.temp (delete existing original.temp, if any); | |
238 | # 2) sed < original.temp > original | |
239 | # 3) delete original.temp | |
240 | # These steps ensure that the output file has the same permissions as the original file. | |
241 | ||
242 | # Configure installed script | |
243 | install-exec-hook: | |
244 | rm -f "$(DESTDIR)$(sbindir)/nzbgetd.temp" | |
245 | cp "$(DESTDIR)$(sbindir)/nzbgetd" "$(DESTDIR)$(sbindir)/nzbgetd.temp" | |
246 | sed 's?/usr/local/bin?$(bindir)?' < "$(DESTDIR)$(sbindir)/nzbgetd.temp" > "$(DESTDIR)$(sbindir)/nzbgetd" | |
247 | rm "$(DESTDIR)$(sbindir)/nzbgetd.temp" | |
248 | ||
249 | # Prepare example configuration file | |
250 | install-data-hook: | |
251 | rm -f "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" | |
252 | cp "$(DESTDIR)$(exampleconfdir)/nzbget.conf" "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" | |
253 | sed 's:^ConfigTemplate=:ConfigTemplate=$(exampleconfdir)/nzbget.conf:' < "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" > "$(DESTDIR)$(exampleconfdir)/nzbget.conf" | |
254 | sed 's:configuration file (typically installed:configuration file (installed:' < "$(DESTDIR)$(exampleconfdir)/nzbget.conf" > "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" | |
255 | sed 's:/usr/local/share/nzbget/nzbget.conf):$(exampleconfdir)/nzbget.conf):' < "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" > "$(DESTDIR)$(exampleconfdir)/nzbget.conf" | |
256 | sed 's:^WebDir=:WebDir=$(webuidir)/webui:' < "$(DESTDIR)$(exampleconfdir)/nzbget.conf" > "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" | |
257 | sed 's:typically installed to /usr/local/share/nzbget/scripts:installed to $(scriptsdir)/scripts:' < "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" > "$(DESTDIR)$(exampleconfdir)/nzbget.conf" | |
258 | rm "$(DESTDIR)$(exampleconfdir)/nzbget.conf.temp" | |
259 | ||
260 | # Install configuration files into /etc | |
261 | # (only if they do not exist there to prevent override by update) | |
262 | install-conf: | |
263 | if test ! -f "$(DESTDIR)$(sysconfdir)/nzbget.conf" ; then \ | |
264 | $(mkinstalldirs) "$(DESTDIR)$(sysconfdir)" ; \ | |
265 | cp "$(DESTDIR)$(exampleconfdir)/nzbget.conf" "$(DESTDIR)$(sysconfdir)/nzbget.conf" ; \ | |
266 | fi | |
267 | ||
268 | uninstall-conf: | |
269 | rm -f "$(DESTDIR)$(sysconfdir)/nzbget.conf" | |
270 | ||
271 | # Determining subversion revision: | |
272 | # 1) If directory ".svn" exists we take revision from it using program svnversion (part of subversion package) | |
273 | # File is recreated only if revision number was changed. | |
274 | # 2) If directory ".svn" doesn't exists we keep and reuse file "svn_version.cpp", | |
275 | # which was possibly created early. | |
276 | # 3) If neither directory ".svn" nor file "svn_version.cpp" are available | |
277 | # we create new file "svn_version.c" with empty revision number. | |
278 | svn_version.cpp: FORCE | |
279 | @ if test -d ./.svn ; then \ | |
280 | V="$(shell svnversion -n .)"; \ | |
281 | H="$(shell test -f ./svn_version.cpp && head -n 1 svn_version.cpp)"; \ | |
282 | if test "/* $$V */" != "$$H" ; then \ | |
283 | ( \ | |
284 | echo "/* $$V */" ;\ | |
285 | echo "/* This file is automatically regenerated on each build. Do not edit it. */" ;\ | |
286 | echo "const char* svn_version(void)" ;\ | |
287 | echo "{" ;\ | |
288 | echo " const char* SVN_Version = \"$$V\";" ;\ | |
289 | echo " return SVN_Version;" ;\ | |
290 | echo "}" ;\ | |
291 | ) > svn_version.cpp ; \ | |
292 | fi \ | |
293 | elif test -f ./svn_version.cpp ; then \ | |
294 | test "ok, reuse existing file"; \ | |
295 | else \ | |
296 | ( \ | |
297 | echo "/* */" ;\ | |
298 | echo "/* This file is automatically regenerated on each build. Do not edit it. */" ;\ | |
299 | echo "const char* svn_version(void)" ;\ | |
300 | echo "{" ;\ | |
301 | echo " const char* SVN_Version = \"\";" ;\ | |
302 | echo " return SVN_Version;" ;\ | |
303 | echo "}" ;\ | |
304 | ) > svn_version.cpp ; \ | |
305 | fi | |
306 | FORCE: | |
307 | ||
308 | # Ignore "svn_version.cpp" in distcleancheck | |
309 | distcleancheck_listfiles = \ | |
310 | find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \ | |
311 | sh '{}' ';' | |
312 | ||
313 | clean-bak: rm *~ | |
314 | ||
315 | # Fix premissions | |
316 | dist-hook: | |
317 | find $(distdir)/daemon -type f -print -exec chmod -x {} \; | |
318 | find $(distdir)/webui -type f -print -exec chmod -x {} \; | |
319 |
0 | # -*- Autoconf -*- | |
1 | # Process this file with autoconf to produce a configure script. | |
2 | ||
3 | AC_PREREQ(2.59) | |
4 | AC_INIT(nzbget, 13.0, hugbug@users.sourceforge.net) | |
5 | AC_CANONICAL_SYSTEM | |
6 | AM_INIT_AUTOMAKE(nzbget, 13.0) | |
7 | AC_CONFIG_SRCDIR([daemon/main/nzbget.cpp]) | |
8 | AC_CONFIG_HEADERS([config.h]) | |
9 | ||
10 | ||
11 | dnl | |
12 | dnl Set default library path, if not specified in environment variable "LIBPREF". | |
13 | dnl | |
14 | if test "$LIBPREF" = ""; then | |
15 | LIBPREF="/usr" | |
16 | fi | |
17 | ||
18 | ||
19 | dnl | |
20 | dnl Check for programs. | |
21 | dnl | |
22 | AC_PROG_CXX | |
23 | AC_PATH_PROG(TAR, tar, $FALSE) | |
24 | AC_PATH_PROG(MAKE, make, $FALSE) | |
25 | AC_PROG_INSTALL | |
26 | ||
27 | ||
28 | dnl | |
29 | dnl Do all tests with c++ compiler. | |
30 | dnl | |
31 | AC_LANG(C++) | |
32 | ||
33 | ||
34 | dnl | |
35 | dnl Checks for header files. | |
36 | dnl | |
37 | AC_CHECK_HEADERS(sys/prctl.h) | |
38 | AC_CHECK_HEADERS(regex.h) | |
39 | ||
40 | ||
41 | dnl | |
42 | dnl Check for libs | |
43 | dnl | |
44 | AC_SEARCH_LIBS([pthread_create], [pthread]) | |
45 | AC_SEARCH_LIBS([socket], [socket]) | |
46 | AC_SEARCH_LIBS([inet_addr], [nsl]) | |
47 | AC_SEARCH_LIBS([hstrerror], [resolv]) | |
48 | ||
49 | ||
50 | dnl | |
51 | dnl Getopt | |
52 | dnl | |
53 | AC_CHECK_FUNC(getopt_long, | |
54 | [AC_DEFINE([HAVE_GETOPT_LONG], 1, [Define to 1 if getopt_long is supported])],) | |
55 | ||
56 | ||
57 | dnl | |
58 | dnl use 64-Bits for file sizes | |
59 | dnl | |
60 | AC_SYS_LARGEFILE | |
61 | ||
62 | ||
63 | dnl | |
64 | dnl check ctime_r | |
65 | dnl | |
66 | AC_MSG_CHECKING(for ctime_r) | |
67 | AC_TRY_COMPILE( | |
68 | [#include <time.h>], | |
69 | [ time_t clock; char buf[26]; ctime_r(&clock, buf, 26); ], | |
70 | AC_MSG_RESULT([[yes, and it takes 3 arguments]]) | |
71 | FOUND="yes" | |
72 | AC_DEFINE([HAVE_CTIME_R_3], 1, [Define to 1 if ctime_r takes 3 arguments]), | |
73 | FOUND="no") | |
74 | if test "$FOUND" = "no"; then | |
75 | AC_TRY_COMPILE( | |
76 | [#include <time.h>], | |
77 | [ time_t clock; char buf[26]; ctime_r(&clock, buf); ], | |
78 | AC_MSG_RESULT([[yes, and it takes 2 arguments]]) | |
79 | FOUND="yes" | |
80 | AC_DEFINE([HAVE_CTIME_R_2], 1, [Define to 1 if ctime_r takes 2 arguments]), | |
81 | FOUND="no") | |
82 | fi | |
83 | if test "$FOUND" = "no"; then | |
84 | AC_MSG_RESULT([no]) | |
85 | AC_MSG_ERROR("function ctime_r not found") | |
86 | fi | |
87 | ||
88 | ||
89 | dnl | |
90 | dnl check getaddrinfo | |
91 | dnl | |
92 | AC_CHECK_FUNC(getaddrinfo, | |
93 | FOUND="yes" | |
94 | [AC_DEFINE([HAVE_GETADDRINFO], 1, [Define to 1 if getaddrinfo is supported])] | |
95 | AC_SEARCH_LIBS([getaddrinfo], [nsl]), | |
96 | FOUND="no") | |
97 | ||
98 | ||
99 | dnl | |
100 | dnl check gethostbyname_r, if getaddrinfo is not available | |
101 | dnl | |
102 | if test "$FOUND" = "no"; then | |
103 | AC_MSG_CHECKING(for gethostbyname_r) | |
104 | ||
105 | AC_TRY_COMPILE( | |
106 | [#include <netdb.h>], | |
107 | [ char* szHost; struct hostent hinfobuf; char* strbuf; int h_errnop; | |
108 | struct hostent* hinfo = gethostbyname_r(szHost, &hinfobuf, strbuf, 1024, &h_errnop); ], | |
109 | AC_MSG_RESULT([[yes, and it takes 5 arguments]]) | |
110 | FOUND="yes" | |
111 | AC_DEFINE([HAVE_GETHOSTBYNAME_R_5], 1, [Define to 1 if gethostbyname_r takes 5 arguments]), | |
112 | FOUND="no") | |
113 | ||
114 | if test "$FOUND" = "no"; then | |
115 | AC_TRY_COMPILE( | |
116 | [#include <netdb.h>], | |
117 | [ char* szHost; struct hostent* hinfo; struct hostent hinfobuf; char* strbuf; int h_errnop; | |
118 | int err = gethostbyname_r(szHost, &hinfobuf, strbuf, 1024, &hinfo, &h_errnop); ], | |
119 | AC_MSG_RESULT([[yes, and it takes 6 arguments]]) | |
120 | FOUND="yes" | |
121 | AC_DEFINE([HAVE_GETHOSTBYNAME_R_6], 1, [Define to 1 if gethostbyname_r takes 6 arguments]), | |
122 | FOUND="no") | |
123 | fi | |
124 | ||
125 | if test "$FOUND" = "no"; then | |
126 | AC_TRY_COMPILE( | |
127 | [#include <netdb.h>], | |
128 | [ char* szHost; struct hostent hinfo; struct hostent_data hinfobuf; | |
129 | int err = gethostbyname_r(szHost, &hinfo, &hinfobuf); ], | |
130 | AC_MSG_RESULT([[yes, and it takes 3 arguments]]) | |
131 | FOUND="yes" | |
132 | AC_DEFINE([HAVE_GETHOSTBYNAME_R_3], 1, [Define to 1 if gethostbyname_r takes 3 arguments]), | |
133 | AC_MSG_RESULT([[no]]) | |
134 | FOUND="no") | |
135 | fi | |
136 | ||
137 | if test "$FOUND" = "yes"; then | |
138 | AC_DEFINE([HAVE_GETHOSTBYNAME_R], 1, [Define to 1 if gethostbyname_r is supported]) | |
139 | AC_SEARCH_LIBS([gethostbyname_r], [nsl]) | |
140 | fi | |
141 | fi | |
142 | ||
143 | ||
144 | dnl | |
145 | dnl cCheck if spinlocks are available | |
146 | dnl | |
147 | AC_CHECK_FUNC(pthread_spin_init, | |
148 | [AC_DEFINE([HAVE_SPINLOCK], 1, [Define to 1 if spinlocks are supported])] | |
149 | AC_SEARCH_LIBS([pthread_spin_init], [pthread]),) | |
150 | ||
151 | ||
152 | dnl | |
153 | dnl Determine what socket length (socklen_t) data type is | |
154 | dnl | |
155 | AC_MSG_CHECKING([for type of socket length (socklen_t)]) | |
156 | AC_TRY_COMPILE([ | |
157 | #include <stddef.h> | |
158 | #include <sys/types.h> | |
159 | #include <sys/socket.h>],[ | |
160 | (void)getsockopt (1, 1, 1, NULL, (socklen_t*)NULL)],[ | |
161 | AC_MSG_RESULT(socklen_t) | |
162 | SOCKLEN_T=socklen_t],[ | |
163 | AC_TRY_COMPILE([ | |
164 | #include <stddef.h> | |
165 | #include <sys/types.h> | |
166 | #include <sys/socket.h>],[ | |
167 | (void)getsockopt (1, 1, 1, NULL, (size_t*)NULL)],[ | |
168 | AC_MSG_RESULT(size_t) | |
169 | SOCKLEN_T=size_t],[ | |
170 | AC_TRY_COMPILE([ | |
171 | #include <stddef.h> | |
172 | #include <sys/types.h> | |
173 | #include <sys/socket.h>],[ | |
174 | (void)getsockopt (1, 1, 1, NULL, (int*)NULL)],[ | |
175 | AC_MSG_RESULT(int) | |
176 | SOCKLEN_T=int],[ | |
177 | AC_MSG_WARN(could not determine) | |
178 | SOCKLEN_T=int])])]) | |
179 | AC_DEFINE_UNQUOTED(SOCKLEN_T, $SOCKLEN_T, [Determine what socket length (socklen_t) data type is]) | |
180 | ||
181 | ||
182 | dnl | |
183 | dnl checks for libxml2 includes and libraries. | |
184 | dnl | |
185 | AC_ARG_WITH(libxml2_includes, | |
186 | [AS_HELP_STRING([--with-libxml2-includes=DIR], [libxml2 include directory])], | |
187 | [CPPFLAGS="${CPPFLAGS} -I${withval}"] | |
188 | [INCVAL="yes"], | |
189 | [INCVAL="no"]) | |
190 | AC_ARG_WITH(libxml2_libraries, | |
191 | [AS_HELP_STRING([--with-libxml2-libraries=DIR], [libxml2 library directory])], | |
192 | [LDFLAGS="${LDFLAGS} -L${withval}"] | |
193 | [LIBVAL="yes"], | |
194 | [LIBVAL="no"]) | |
195 | if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then | |
196 | PKG_CHECK_MODULES(libxml2, libxml-2.0, | |
197 | [LIBS="${LIBS} $libxml2_LIBS"] | |
198 | [CPPFLAGS="${CPPFLAGS} $libxml2_CFLAGS"]) | |
199 | fi | |
200 | AC_CHECK_HEADER(libxml/tree.h,, | |
201 | AC_MSG_ERROR("libxml2 header files not found")) | |
202 | AC_SEARCH_LIBS([xmlNewNode], [xml2], , | |
203 | AC_MSG_ERROR("libxml2 library not found")) | |
204 | ||
205 | ||
206 | dnl | |
207 | dnl Use curses. Deafult: yes | |
208 | dnl | |
209 | AC_MSG_CHECKING(whether to use curses) | |
210 | AC_ARG_ENABLE(curses, | |
211 | [AS_HELP_STRING([--disable-curses], [do not use curses (removes dependency from curses-library)])], | |
212 | [USECURSES=$enableval], | |
213 | [USECURSES=yes] ) | |
214 | AC_MSG_RESULT($USECURSES) | |
215 | if test "$USECURSES" = "yes"; then | |
216 | INCVAL="${LIBPREF}/include" | |
217 | LIBVAL="${LIBPREF}/lib" | |
218 | AC_ARG_WITH(libcurses_includes, | |
219 | [AS_HELP_STRING([--with-libcurses-includes=DIR], [libcurses include directory])], | |
220 | [INCVAL="$withval"]) | |
221 | CPPFLAGS="${CPPFLAGS} -I${INCVAL}" | |
222 | AC_ARG_WITH(libcurses_libraries, | |
223 | [AS_HELP_STRING([--with-libcurses-libraries=DIR], [libcurses library directory])], | |
224 | [LIBVAL="$withval"]) | |
225 | LDFLAGS="${LDFLAGS} -L${LIBVAL}" | |
226 | ||
227 | AC_CHECK_HEADER(ncurses.h, | |
228 | FOUND=yes | |
229 | AC_DEFINE([HAVE_NCURSES_H],1,[Define to 1 if you have the <ncurses.h> header file.]), | |
230 | FOUND=no) | |
231 | if test "$FOUND" = "no"; then | |
232 | AC_CHECK_HEADER(ncurses/ncurses.h, | |
233 | FOUND=yes | |
234 | AC_DEFINE([HAVE_NCURSES_NCURSES_H],1,[Define to 1 if you have the <ncurses/ncurses.h> header file.]), | |
235 | FOUND=no) | |
236 | fi | |
237 | if test "$FOUND" = "no"; then | |
238 | AC_CHECK_HEADER(curses.h, | |
239 | FOUND=yes | |
240 | AC_DEFINE([HAVE_CURSES_H],1,[Define to 1 if you have the <curses.h> header file.]), | |
241 | FOUND=no) | |
242 | fi | |
243 | if test "$FOUND" = "no"; then | |
244 | AC_MSG_ERROR([Couldn't find curses headers (ncurses.h or curses.h)]) | |
245 | fi | |
246 | AC_SEARCH_LIBS([refresh], [ncurses curses],, | |
247 | AC_ERROR([Couldn't find curses library])) | |
248 | else | |
249 | AC_DEFINE([DISABLE_CURSES],1,[Define to 1 to not use curses]) | |
250 | fi | |
251 | ||
252 | ||
253 | dnl | |
254 | dnl Use libpar2 for par-checking. Deafult: no | |
255 | dnl | |
256 | AC_MSG_CHECKING(whether to include code for par-checking) | |
257 | AC_ARG_ENABLE(parcheck, | |
258 | [AS_HELP_STRING([--disable-parcheck], [do not include par-check/-repair-support (removes dependency from libpar2- and libsigc-libraries)])], | |
259 | [ ENABLEPARCHECK=$enableval ], | |
260 | [ ENABLEPARCHECK=yes] ) | |
261 | AC_MSG_RESULT($ENABLEPARCHECK) | |
262 | if test "$ENABLEPARCHECK" = "yes"; then | |
263 | ||
264 | dnl | |
265 | dnl checks for libsigc++ includes and libraries (required for libpar2). | |
266 | dnl | |
267 | ||
268 | AC_ARG_WITH(libsigc_includes, | |
269 | [AS_HELP_STRING([--with-libsigc-includes=DIR], [libsigc++-2.0 include directory])], | |
270 | [CPPFLAGS="${CPPFLAGS} -I${withval}"] | |
271 | [INCVAL="yes"], | |
272 | [INCVAL="no"]) | |
273 | AC_ARG_WITH(libsigc_libraries, | |
274 | [AS_HELP_STRING([--with-libsigc-libraries=DIR], [libsigc++-2.0 library directory])], | |
275 | [LDFLAGS="${LDFLAGS} -L${withval}"] | |
276 | [CPPFLAGS="${CPPFLAGS} -I${withval}/sigc++-2.0/include"] | |
277 | [LIBVAL="yes"], | |
278 | [LIBVAL="no"]) | |
279 | if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then | |
280 | PKG_CHECK_MODULES(libsigc, sigc++-2.0, | |
281 | [LIBS="${LIBS} $libsigc_LIBS"] | |
282 | [CPPFLAGS="${CPPFLAGS} $libsigc_CFLAGS"]) | |
283 | fi | |
284 | ||
285 | AC_CHECK_HEADER(sigc++/type_traits.h,, | |
286 | AC_MSG_ERROR("libsigc++-2.0 header files not found")) | |
287 | ||
288 | dnl | |
289 | dnl checks for libpar2 includes and libraries. | |
290 | dnl | |
291 | INCVAL="${LIBPREF}/include" | |
292 | LIBVAL="${LIBPREF}/lib" | |
293 | AC_ARG_WITH(libpar2_includes, | |
294 | [AS_HELP_STRING([--with-libpar2-includes=DIR], [libpar2 include directory])], | |
295 | [INCVAL="$withval"]) | |
296 | ||
297 | CPPFLAGS="${CPPFLAGS} -I${INCVAL}" | |
298 | ||
299 | AC_CHECK_HEADER(libpar2/libpar2.h,, | |
300 | AC_MSG_ERROR("libpar2 header files not found")) | |
301 | ||
302 | AC_ARG_WITH(libpar2_libraries, | |
303 | [AS_HELP_STRING([--with-libpar2-libraries=DIR], [libpar2 library directory])], | |
304 | [LIBVAL="$withval"]) | |
305 | ||
306 | LDFLAGS="${LDFLAGS} -L${LIBVAL}" | |
307 | ||
308 | AC_SEARCH_LIBS([_ZN12Par2RepairerC1Ev], [par2], , | |
309 | AC_MSG_ERROR("libpar2 library not found")) | |
310 | ||
311 | dnl | |
312 | dnl check if libpar2 library is linkable | |
313 | dnl | |
314 | AC_MSG_CHECKING(for libpar2 linking) | |
315 | AC_TRY_LINK( | |
316 | [#include <libpar2/par2cmdline.h>] | |
317 | [#include <libpar2/par2repairer.h>] | |
318 | [ class Repairer : public Par2Repairer { }; ], | |
319 | [ Repairer* p = new Repairer(); ], | |
320 | AC_MSG_RESULT([[yes]]), | |
321 | AC_MSG_RESULT([[no]]) | |
322 | AC_MSG_ERROR("libpar2 library not found")) | |
323 | ||
324 | dnl | |
325 | dnl check if libpar2 has support for cancelling | |
326 | dnl | |
327 | AC_MSG_CHECKING(whether libpar2 supports cancelling) | |
328 | AC_TRY_COMPILE( | |
329 | [#include <libpar2/par2cmdline.h>] | |
330 | [#include <libpar2/par2repairer.h>] | |
331 | [ class Repairer : public Par2Repairer { void test() { cancelled = true; } }; ], | |
332 | [], | |
333 | AC_MSG_RESULT([[yes]]) | |
334 | AC_DEFINE([HAVE_PAR2_CANCEL], 1, [Define to 1 if libpar2 supports cancelling (needs a special patch)]), | |
335 | AC_MSG_RESULT([[no]])) | |
336 | ||
337 | dnl | |
338 | dnl check if libpar2 has recent bugfixes-patch | |
339 | dnl | |
340 | AC_MSG_CHECKING(whether libpar2 has recent bugfixes) | |
341 | AC_TRY_COMPILE( | |
342 | [#include <libpar2/par2cmdline.h>] | |
343 | [#include <libpar2/par2repairer.h>] | |
344 | [ class Repairer : public Par2Repairer { void test() { BugfixesPatchVersion2(); } }; ], | |
345 | [], | |
346 | AC_MSG_RESULT([[yes]]) | |
347 | PAR2PATCHV2=yes | |
348 | AC_DEFINE([HAVE_PAR2_BUGFIXES_V2], 1, [Define to 1 if libpar2 has recent bugfixes-patch (version 2)]), | |
349 | AC_MSG_RESULT([[no]]) | |
350 | PAR2PATCHV2=no) | |
351 | ||
352 | if test "$PAR2PATCHV2" = "no" ; then | |
353 | AC_ARG_ENABLE(libpar2-bugfixes-check, | |
354 | [AS_HELP_STRING([--disable-libpar2-bugfixes-check], [do not check libpar2 version])], | |
355 | [ PAR2PATCHCHECK=$enableval ], | |
356 | [ PAR2PATCHCHECK=yes] ) | |
357 | if test "$PAR2PATCHCHECK" = "yes"; then | |
358 | AC_ERROR([Your version of libpar2 doesn't include the recent bugfixes. Please update libpar2 to version 0.4 or newer (http://launchpad.net/libpar2). If you cannot install a newer version of libpar2, you can use configure parameter --disable-libpar2-bugfixes-check to suppress the check. Please note however that in this case the program may crash during par-check/repair. The update is highly recommended!]) | |
359 | fi | |
360 | fi | |
361 | ||
362 | else | |
363 | AC_DEFINE([DISABLE_PARCHECK],1,[Define to 1 to disable smart par-verification and restoration]) | |
364 | fi | |
365 | ||
366 | ||
367 | dnl | |
368 | dnl Use TLS/SSL. Deafult: yes | |
369 | dnl | |
370 | AC_MSG_CHECKING(whether to use TLS/SSL) | |
371 | AC_ARG_ENABLE(tls, | |
372 | [AS_HELP_STRING([--disable-tls], [do not use TLS/SSL (removes dependency from TLS/SSL-libraries)])], | |
373 | [ USETLS=$enableval ], | |
374 | [ USETLS=yes] ) | |
375 | AC_MSG_RESULT($USETLS) | |
376 | if test "$USETLS" = "yes"; then | |
377 | AC_ARG_WITH(tlslib, | |
378 | [AS_HELP_STRING([--with-tlslib=(OpenSSL, GnuTLS)], [TLS/SSL library to use])], | |
379 | [TLSLIB="$withval"]) | |
380 | if test "$TLSLIB" != "GnuTLS" -a "$TLSLIB" != "OpenSSL" -a "$TLSLIB" != ""; then | |
381 | AC_MSG_ERROR([Invalid argument for option --with-tlslib]) | |
382 | fi | |
383 | ||
384 | if test "$TLSLIB" = "OpenSSL" -o "$TLSLIB" = ""; then | |
385 | AC_ARG_WITH(openssl_includes, | |
386 | [AS_HELP_STRING([--with-openssl-includes=DIR], [OpenSSL include directory])], | |
387 | [CPPFLAGS="${CPPFLAGS} -I${withval}"] | |
388 | [INCVAL="yes"], | |
389 | [INCVAL="no"]) | |
390 | AC_ARG_WITH(openssl_libraries, | |
391 | [AS_HELP_STRING([--with-openssl-libraries=DIR], [OpenSSL library directory])], | |
392 | [LDFLAGS="${LDFLAGS} -L${withval}"] | |
393 | [LIBVAL="yes"], | |
394 | [LIBVAL="no"]) | |
395 | if test "$INCVAL" = "no" -o "$LIBVAL" = "no"; then | |
396 | PKG_CHECK_MODULES(openssl, openssl, | |
397 | [LIBS="${LIBS} $openssl_LIBS"] | |
398 | [CPPFLAGS="${CPPFLAGS} $openssl_CFLAGS"], | |
399 | FOUND=yes | |
400 | FOUND=no) | |
401 | fi | |
402 | ||
403 | AC_CHECK_HEADER(openssl/ssl.h, | |
404 | FOUND=yes | |
405 | TLSHEADERS=yes, | |
406 | FOUND=no) | |
407 | if test "$FOUND" = "no" -a "$TLSLIB" = "OpenSSL"; then | |
408 | AC_MSG_ERROR([Couldn't find OpenSSL headers (ssl.h)]) | |
409 | fi | |
410 | if test "$FOUND" = "yes"; then | |
411 | AC_SEARCH_LIBS([CRYPTO_set_locking_callback], [crypto], | |
412 | AC_SEARCH_LIBS([SSL_library_init], [ssl], | |
413 | FOUND=yes, | |
414 | FOUND=no), | |
415 | FOUND=no) | |
416 | if test "$FOUND" = "no" -a "$TLSLIB" = "OpenSSL"; then | |
417 | AC_MSG_ERROR([Couldn't find OpenSSL library]) | |
418 | fi | |
419 | if test "$FOUND" = "yes"; then | |
420 | TLSLIB="OpenSSL" | |
421 | AC_DEFINE([HAVE_OPENSSL],1,[Define to 1 to use OpenSSL library for TLS/SSL-support.]) | |
422 | fi | |
423 | fi | |
424 | fi | |
425 | ||
426 | if test "$TLSLIB" = "GnuTLS" -o "$TLSLIB" = ""; then | |
427 | INCVAL="${LIBPREF}/include" | |
428 | LIBVAL="${LIBPREF}/lib" | |
429 | AC_ARG_WITH(libgnutls_includes, | |
430 | [AS_HELP_STRING([--with-libgnutls-includes=DIR], [GnuTLS include directory])], | |
431 | [INCVAL="$withval"]) | |
432 | CPPFLAGS="${CPPFLAGS} -I${INCVAL}" | |
433 | AC_ARG_WITH(libgnutls_libraries, | |
434 | [AS_HELP_STRING([--with-libgnutls-libraries=DIR], [GnuTLS library directory])], | |
435 | [LIBVAL="$withval"]) | |
436 | LDFLAGS="${LDFLAGS} -L${LIBVAL}" | |
437 | ||
438 | AC_CHECK_HEADER(gnutls/gnutls.h, | |
439 | FOUND=yes | |
440 | TLSHEADERS=yes, | |
441 | FOUND=no) | |
442 | if test "$FOUND" = "no" -a "$TLSLIB" = "GnuTLS"; then | |
443 | AC_MSG_ERROR([Couldn't find GnuTLS headers (gnutls.h)]) | |
444 | fi | |
445 | if test "$FOUND" = "yes"; then | |
446 | AC_SEARCH_LIBS([gnutls_global_init], [gnutls], | |
447 | AC_SEARCH_LIBS([gcry_control], [gnutls gcrypt], | |
448 | FOUND=yes, | |
449 | FOUND=no), | |
450 | FOUND=no) | |
451 | if test "$FOUND" = "no" -a "$TLSLIB" = "GnuTLS"; then | |
452 | AC_MSG_ERROR([Couldn't find GnuTLS library]) | |
453 | fi | |
454 | if test "$FOUND" = "yes"; then | |
455 | TLSLIB="GnuTLS" | |
456 | AC_DEFINE([HAVE_LIBGNUTLS],1,[Define to 1 to use GnuTLS library for TLS/SSL-support.]) | |
457 | fi | |
458 | fi | |
459 | fi | |
460 | ||
461 | if test "$TLSLIB" = ""; then | |
462 | if test "$TLSHEADERS" = ""; then | |
463 | AC_MSG_ERROR([Couldn't find neither OpenSSL nor GnuTLS headers (ssl.h or gnutls.h)]) | |
464 | else | |
465 | AC_MSG_ERROR([Couldn't find neither OpenSSL nor GnuTLS library]) | |
466 | fi | |
467 | fi | |
468 | else | |
469 | AC_DEFINE([DISABLE_TLS],1,[Define to 1 to not use TLS/SSL]) | |
470 | fi | |
471 | ||
472 | ||
473 | dnl | |
474 | dnl checks for zlib includes and libraries. | |
475 | dnl | |
476 | AC_MSG_CHECKING(whether to use gzip) | |
477 | AC_ARG_ENABLE(gzip, | |
478 | [AS_HELP_STRING([--disable-gzip], [disable gzip-compression/decompression (removes dependency from zlib-library)])], | |
479 | [USEZLIB=$enableval], | |
480 | [USEZLIB=yes] ) | |
481 | AC_MSG_RESULT($USEZLIB) | |
482 | if test "$USEZLIB" = "yes"; then | |
483 | INCVAL="${LIBPREF}/include" | |
484 | LIBVAL="${LIBPREF}/lib" | |
485 | AC_ARG_WITH(zlib_includes, | |
486 | [AS_HELP_STRING([--with-zlib-includes=DIR], [zlib include directory])], | |
487 | [INCVAL="$withval"]) | |
488 | CPPFLAGS="${CPPFLAGS} -I${INCVAL}" | |
489 | AC_ARG_WITH(zlib_libraries, | |
490 | [AS_HELP_STRING([--with-zlib-libraries=DIR], [zlib library directory])], | |
491 | [LIBVAL="$withval"]) | |
492 | LDFLAGS="${LDFLAGS} -L${LIBVAL}" | |
493 | ||
494 | AC_CHECK_HEADER(zlib.h,, | |
495 | AC_MSG_ERROR("zlib header files not found")) | |
496 | AC_SEARCH_LIBS([deflateBound], [z], , | |
497 | AC_MSG_ERROR("zlib library not found")) | |
498 | else | |
499 | AC_DEFINE([DISABLE_GZIP],1,[Define to 1 to disable gzip-support]) | |
500 | fi | |
501 | ||
502 | ||
503 | dnl | |
504 | dnl Some Linux systems require an empty signal handler for SIGCHLD | |
505 | dnl in order for exit codes to be correctly delivered to parent process. | |
506 | dnl Some 32-Bit BSD systems however may not function properly if the handler is installed. | |
507 | dnl The default behavior is to install the handler. | |
508 | dnl | |
509 | AC_MSG_CHECKING(whether to use an empty SIGCHLD handler) | |
510 | AC_ARG_ENABLE(sigchld-handler, | |
511 | [AS_HELP_STRING([--disable-sigchld-handler], [do not use sigchld-handler (the disabling may be neccessary on 32-Bit BSD)])], | |
512 | [SIGCHLDHANDLER=$enableval], | |
513 | [SIGCHLDHANDLER=yes]) | |
514 | AC_MSG_RESULT($SIGCHLDHANDLER) | |
515 | if test "$SIGCHLDHANDLER" = "yes"; then | |
516 | AC_DEFINE([SIGCHLD_HANDLER], 1, [Define to 1 to install an empty signal handler for SIGCHLD]) | |
517 | fi | |
518 | ||
519 | ||
520 | dnl | |
521 | dnl Debugging. Default: no | |
522 | dnl | |
523 | AC_MSG_CHECKING(whether to include all debugging code) | |
524 | AC_ARG_ENABLE(debug, | |
525 | [AS_HELP_STRING([--enable-debug], [enable debugging])], | |
526 | [ ENABLEDEBUG=$enableval ], | |
527 | [ ENABLEDEBUG=no] ) | |
528 | AC_MSG_RESULT($ENABLEDEBUG) | |
529 | ||
530 | ||
531 | if test "$ENABLEDEBUG" = "yes"; then | |
532 | ||
533 | dnl | |
534 | dnl Begin of debugging code | |
535 | dnl | |
536 | ||
537 | AC_DEFINE([DEBUG],1,Define to 1 to include debug-code) | |
538 | ||
539 | ||
540 | dnl | |
541 | dnl Set debug flags for gcc (if gcc is used) | |
542 | dnl | |
543 | if test "$CC" = "gcc"; then | |
544 | CXXFLAGS="-g -Wall" | |
545 | else | |
546 | CXXFLAGS="" | |
547 | fi | |
548 | ||
549 | ||
550 | dnl | |
551 | dnl check for __FUNCTION__ or __func__ macro | |
552 | dnl | |
553 | AC_MSG_CHECKING(for macro returning current function name) | |
554 | AC_TRY_COMPILE( | |
555 | [#include <stdio.h>], [printf("%s\n", __FUNCTION__);], | |
556 | AC_MSG_RESULT(__FUNCTION__) | |
557 | FUNCTION_MACRO_NAME=__FUNCTION__, | |
558 | AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);], | |
559 | AC_MSG_RESULT(__func__) | |
560 | FUNCTION_MACRO_NAME=__func__, | |
561 | AC_MSG_RESULT(none))) | |
562 | if test "$FUNCTION_MACRO_NAME" != ""; then | |
563 | AC_DEFINE_UNQUOTED(FUNCTION_MACRO_NAME, $FUNCTION_MACRO_NAME, [Define to the name of macro which returns the name of function being compiled]) | |
564 | fi | |
565 | ||
566 | ||
567 | dnl | |
568 | dnl variadic macros | |
569 | dnl | |
570 | AC_MSG_CHECKING(for variadic macros) | |
571 | AC_COMPILE_IFELSE([ | |
572 | #define macro(...) macrofunc(__VA_ARGS__) | |
573 | int macrofunc(int a, int b) { return a + b; } | |
574 | int test() { return macro(1, 2); } | |
575 | ], | |
576 | AC_MSG_RESULT([yes]) | |
577 | AC_DEFINE([HAVE_VARIADIC_MACROS], 1, Define to 1 if variadic macros are supported), | |
578 | AC_MSG_RESULT([no])) | |
579 | ||
580 | ||
581 | dnl | |
582 | dnl Backtracing on segmentation faults | |
583 | dnl | |
584 | AC_MSG_CHECKING(for backtrace) | |
585 | AC_TRY_COMPILE( | |
586 | [#include <execinfo.h>] | |
587 | [#include <stdio.h>] | |
588 | [#include <stdlib.h>], | |
589 | [ void *array[100]; size_t size; char **strings; ] | |
590 | [ size = backtrace(array, 100); ] | |
591 | [ strings = backtrace_symbols(array, size); ], | |
592 | FOUND=yes | |
593 | AC_MSG_RESULT([[yes]]) | |
594 | AC_DEFINE([HAVE_BACKTRACE], 1, [Define to 1 to create stacktrace on segmentation faults]), | |
595 | FOUND=no | |
596 | AC_MSG_RESULT([[no]])) | |
597 | ||
598 | ||
599 | dnl | |
600 | dnl "rdynamic" linker flag | |
601 | dnl | |
602 | AC_MSG_CHECKING(for rdynamic linker flag) | |
603 | old_LDFLAGS="$LDFLAGS" | |
604 | LDFLAGS="$LDFLAGS -rdynamic" | |
605 | AC_TRY_LINK([], [], | |
606 | AC_MSG_RESULT([[yes]]), | |
607 | AC_MSG_RESULT([[no]]) | |
608 | [LDFLAGS="$old_LDFLAGS"]) | |
609 | ||
610 | dnl | |
611 | dnl End of debugging code | |
612 | dnl | |
613 | fi | |
614 | ||
615 | ||
616 | AC_CONFIG_FILES([Makefile]) | |
617 | AC_OUTPUT |
0 | /* | |
1 | * This file is part of nzbget | |
2 | * | |
3 | * Copyright (C) 2014 Andrey Prygunkov <hugbug@users.sourceforge.net> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
18 | * | |
19 | * $Revision: 1042 $ | |
20 | * $Date: 2014-06-12 22:57:00 +0200 (Thu, 12 Jun 2014) $ | |
21 | * | |
22 | */ | |
23 | ||
24 | ||
25 | #ifdef HAVE_CONFIG_H | |
26 | #include "config.h" | |
27 | #endif | |
28 | ||
29 | #ifdef WIN32 | |
30 | #include "win32.h" | |
31 | #endif | |
32 | ||
33 | #include <stdlib.h> | |
34 | #include <string.h> | |
35 | #include <stdio.h> | |
36 | ||
37 | #include "nzbget.h" | |
38 | #include "StatMeter.h" | |
39 | #include "Options.h" | |
40 | #include "ServerPool.h" | |
41 | #include "DiskState.h" | |
42 | ||
43 | extern ServerPool* g_pServerPool; | |
44 | extern Options* g_pOptions; | |
45 | extern DiskState* g_pDiskState; | |
46 | ||
47 | static const int DAYS_UP_TO_2013_JAN_1 = 15706; | |
48 | static const int DAYS_IN_TWENTY_YEARS = 366*20; | |
49 | ||
50 | ServerVolume::ServerVolume() | |
51 | { | |
52 | m_BytesPerSeconds.resize(60); | |
53 | m_BytesPerMinutes.resize(60); | |
54 | m_BytesPerHours.resize(24); | |
55 | m_BytesPerDays.resize(0); | |
56 | m_iFirstDay = 0; | |
57 | m_tDataTime = 0; | |
58 | m_lTotalBytes = 0; | |
59 | m_lCustomBytes = 0; | |
60 | m_tCustomTime = time(NULL); | |
61 | m_iSecSlot = 0; | |
62 | m_iMinSlot = 0; | |
63 | m_iHourSlot = 0; | |
64 | m_iDaySlot = 0; | |
65 | } | |
66 | ||
67 | void ServerVolume::CalcSlots(time_t tLocCurTime) | |
68 | { | |
69 | m_iSecSlot = (int)tLocCurTime % 60; | |
70 | m_iMinSlot = ((int)tLocCurTime / 60) % 60; | |
71 | m_iHourSlot = ((int)tLocCurTime % 86400) / 3600; | |
72 | int iDaysSince1970 = (int)tLocCurTime / 86400; | |
73 | m_iDaySlot = iDaysSince1970 - DAYS_UP_TO_2013_JAN_1 + 1; | |
74 | if (0 <= m_iDaySlot && m_iDaySlot < DAYS_IN_TWENTY_YEARS) | |
75 | { | |
76 | int iCurDay = iDaysSince1970; | |
77 | if (m_iFirstDay == 0 || m_iFirstDay > iCurDay) | |
78 | { | |
79 | m_iFirstDay = iCurDay; | |
80 | } | |
81 | m_iDaySlot = iCurDay - m_iFirstDay; | |
82 | if (m_iDaySlot + 1 > (int)m_BytesPerDays.size()) | |
83 | { | |
84 | m_BytesPerDays.resize(m_iDaySlot + 1); | |
85 | } | |
86 | } | |
87 | else | |
88 | { | |
89 | m_iDaySlot = -1; | |
90 | } | |
91 | } | |
92 | ||
93 | void ServerVolume::AddData(int iBytes) | |
94 | { | |
95 | time_t tCurTime = time(NULL); | |
96 | time_t tLocCurTime = tCurTime + g_pOptions->GetLocalTimeOffset(); | |
97 | time_t tLocDataTime = m_tDataTime + g_pOptions->GetLocalTimeOffset(); | |
98 | ||
99 | int iLastMinSlot = m_iMinSlot; | |
100 | int iLastHourSlot = m_iHourSlot; | |
101 | ||
102 | CalcSlots(tLocCurTime); | |
103 | ||
104 | if (tLocCurTime != tLocDataTime) | |
105 | { | |
106 | // clear seconds/minutes/hours slots if necessary | |
107 | // also handle the backwards changes of system clock | |
108 | ||
109 | int iTotalDelta = (int)(tLocCurTime - tLocDataTime); | |
110 | int iDeltaSign = iTotalDelta >= 0 ? 1 : -1; | |
111 | iTotalDelta = abs(iTotalDelta); | |
112 | ||
113 | int iSecDelta = iTotalDelta; | |
114 | if (iDeltaSign < 0) iSecDelta++; | |
115 | if (iSecDelta >= 60) iSecDelta = 60; | |
116 | for (int i = 0; i < iSecDelta; i++) | |
117 | { | |
118 | int iNulSlot = m_iSecSlot - i * iDeltaSign; | |
119 | if (iNulSlot < 0) iNulSlot += 60; | |
120 | if (iNulSlot >= 60) iNulSlot -= 60; | |
121 | m_BytesPerSeconds[iNulSlot] = 0; | |
122 | } | |
123 | ||
124 | int iMinDelta = iTotalDelta / 60; | |
125 | if (iDeltaSign < 0) iMinDelta++; | |
126 | if (abs(iMinDelta) >= 60) iMinDelta = 60; | |
127 | if (iMinDelta == 0 && m_iMinSlot != iLastMinSlot) iMinDelta = 1; | |
128 | for (int i = 0; i < iMinDelta; i++) | |
129 | { | |
130 | int iNulSlot = m_iMinSlot - i * iDeltaSign; | |
131 | if (iNulSlot < 0) iNulSlot += 60; | |
132 | if (iNulSlot >= 60) iNulSlot -= 60; | |
133 | m_BytesPerMinutes[iNulSlot] = 0; | |
134 | } | |
135 | ||
136 | int iHourDelta = iTotalDelta / (60 * 60); | |
137 | if (iDeltaSign < 0) iHourDelta++; | |
138 | if (iHourDelta >= 24) iHourDelta = 24; | |
139 | if (iHourDelta == 0 && m_iHourSlot != iLastHourSlot) iHourDelta = 1; | |
140 | for (int i = 0; i < iHourDelta; i++) | |
141 | { | |
142 | int iNulSlot = m_iHourSlot - i * iDeltaSign; | |
143 | if (iNulSlot < 0) iNulSlot += 24; | |
144 | if (iNulSlot >= 24) iNulSlot -= 24; | |
145 | m_BytesPerHours[iNulSlot] = 0; | |
146 | } | |
147 | } | |
148 | ||
149 | // add bytes to every slot | |
150 | m_BytesPerSeconds[m_iSecSlot] += iBytes; | |
151 | m_BytesPerMinutes[m_iMinSlot] += iBytes; | |
152 | m_BytesPerHours[m_iHourSlot] += iBytes; | |
153 | if (m_iDaySlot >= 0) | |
154 | { | |
155 | m_BytesPerDays[m_iDaySlot] += iBytes; | |
156 | } | |
157 | m_lTotalBytes += iBytes; | |
158 | m_lCustomBytes += iBytes; | |
159 | ||
160 | m_tDataTime = tCurTime; | |
161 | } | |
162 | ||
163 | void ServerVolume::ResetCustom() | |
164 | { | |
165 | m_lCustomBytes = 0; | |
166 | m_tCustomTime = time(NULL); | |
167 | } | |
168 | ||
169 | void ServerVolume::LogDebugInfo() | |
170 | { | |
171 | info(" ---------- ServerVolume"); | |
172 | ||
173 | char szSec[4000]; | |
174 | ||
175 | szSec[0] = '\0'; | |
176 | for (int i = 0; i < 60; i++) | |
177 | { | |
178 | char szNum[20]; | |
179 | snprintf(szNum, 20, "[%i]=%lli ", i, m_BytesPerSeconds[i]); | |
180 | strncat(szSec, szNum, 4000); | |
181 | } | |
182 | info("Secs: %s", szSec); | |
183 | ||
184 | szSec[0] = '\0'; | |
185 | for (int i = 0; i < 60; i++) | |
186 | { | |
187 | char szNum[20]; | |
188 | snprintf(szNum, 20, "[%i]=%lli ", i, m_BytesPerMinutes[i]); | |
189 | strncat(szSec, szNum, 4000); | |
190 | } | |
191 | info("Mins: %s", szSec); | |
192 | ||
193 | szSec[0] = '\0'; | |
194 | for (int i = 0; i < 24; i++) | |
195 | { | |
196 | char szNum[20]; | |
197 | snprintf(szNum, 20, "[%i]=%lli ", i, m_BytesPerHours[i]); | |
198 | strncat(szSec, szNum, 4000); | |
199 | } | |
200 | info("Hours: %s", szSec); | |
201 | ||
202 | szSec[0] = '\0'; | |
203 | for (int i = 0; i < (int)m_BytesPerDays.size(); i++) | |
204 | { | |
205 | char szNum[20]; | |
206 | snprintf(szNum, 20, "[%i]=%lli ", m_iFirstDay + i, m_BytesPerDays[i]); | |
207 | strncat(szSec, szNum, 4000); | |
208 | } | |
209 | info("Days: %s", szSec); | |
210 | } | |
211 | ||
212 | StatMeter::StatMeter() | |
213 | { | |
214 | debug("Creating StatMeter"); | |
215 | ||
216 | ResetSpeedStat(); | |
217 | ||
218 | m_iAllBytes = 0; | |
219 | m_tStartDownload = 0; | |
220 | m_tPausedFrom = 0; | |
221 | m_bStandBy = true; | |
222 | m_tStartServer = 0; | |
223 | m_tLastCheck = 0; | |
224 | m_tLastTimeOffset = 0; | |
225 | m_bStatChanged = false; | |
226 | ||
227 | g_pLog->RegisterDebuggable(this); | |
228 | } | |
229 | ||
230 | StatMeter::~StatMeter() | |
231 | { | |
232 | debug("Destroying StatMeter"); | |
233 | // Cleanup | |
234 | ||
235 | g_pLog->UnregisterDebuggable(this); | |
236 | ||
237 | for (ServerVolumes::iterator it = m_ServerVolumes.begin(); it != m_ServerVolumes.end(); it++) | |
238 | { | |
239 | delete *it; | |
240 | } | |
241 | ||
242 | debug("StatMeter destroyed"); | |
243 | } | |
244 | ||
245 | void StatMeter::Init() | |
246 | { | |
247 | m_tStartServer = time(NULL); | |
248 | m_tLastCheck = m_tStartServer; | |
249 | AdjustTimeOffset(); | |
250 | ||
251 | m_ServerVolumes.resize(1 + g_pServerPool->GetServers()->size()); | |
252 | m_ServerVolumes[0] = new ServerVolume(); | |
253 | for (Servers::iterator it = g_pServerPool->GetServers()->begin(); it != g_pServerPool->GetServers()->end(); it++) | |
254 | { | |
255 | NewsServer* pServer = *it; | |
256 | m_ServerVolumes[pServer->GetID()] = new ServerVolume(); | |
257 | } | |
258 | } | |
259 | ||
260 | void StatMeter::AdjustTimeOffset() | |
261 | { | |
262 | time_t tUtcTime = time(NULL); | |
263 | tm tmSplittedTime; | |
264 | gmtime_r(&tUtcTime, &tmSplittedTime); | |
265 | tmSplittedTime.tm_isdst = -1; | |
266 | time_t tLocTime = mktime(&tmSplittedTime); | |
267 | time_t tLocalTimeDelta = tUtcTime - tLocTime; | |
268 | g_pOptions->SetLocalTimeOffset((int)tLocalTimeDelta + g_pOptions->GetTimeCorrection()); | |
269 | m_tLastTimeOffset = tUtcTime; | |
270 | ||
271 | debug("UTC delta: %i (%i+%i)", g_pOptions->GetLocalTimeOffset(), (int)tLocalTimeDelta, g_pOptions->GetTimeCorrection()); | |
272 | } | |
273 | ||
274 | /* | |
275 | * Called once per second. | |
276 | * - detect large step changes of system time and adjust statistics; | |
277 | * - save volume stats (if changed). | |
278 | */ | |
279 | void StatMeter::IntervalCheck() | |
280 | { | |
281 | time_t m_tCurTime = time(NULL); | |
282 | time_t tDiff = m_tCurTime - m_tLastCheck; | |
283 | if (tDiff > 60 || tDiff < 0) | |
284 | { | |
285 | m_tStartServer += tDiff + 1; // "1" because the method is called once per second | |
286 | if (m_tStartDownload != 0 && !m_bStandBy) | |
287 | { | |
288 | m_tStartDownload += tDiff + 1; | |
289 | } | |
290 | AdjustTimeOffset(); | |
291 | } | |
292 | else if (m_tLastTimeOffset > m_tCurTime || | |
293 | m_tCurTime - m_tLastTimeOffset > 60 * 60 * 3 || | |
294 | (m_tCurTime - m_tLastTimeOffset > 60 && !m_bStandBy)) | |
295 | { | |
296 | // checking time zone settings may prevent the device from entering sleep/hibernate mode | |
297 | // check every minute if not in standby | |
298 | // check at least every 3 hours even in standby | |
299 | AdjustTimeOffset(); | |
300 | } | |
301 | ||
302 | m_tLastCheck = m_tCurTime; | |
303 | ||
304 | if (m_bStatChanged) | |
305 | { | |
306 | Save(); | |
307 | } | |
308 | } | |
309 | ||
310 | void StatMeter::EnterLeaveStandBy(bool bEnter) | |
311 | { | |
312 | m_mutexStat.Lock(); | |
313 | m_bStandBy = bEnter; | |
314 | if (bEnter) | |
315 | { | |
316 | m_tPausedFrom = time(NULL); | |
317 | } | |
318 | else | |
319 | { | |
320 | if (m_tStartDownload == 0) | |
321 | { | |
322 | m_tStartDownload = time(NULL); | |
323 | } | |
324 | else | |
325 | { | |
326 | m_tStartDownload += time(NULL) - m_tPausedFrom; | |
327 | } | |
328 | m_tPausedFrom = 0; | |
329 | ResetSpeedStat(); | |
330 | } | |
331 | m_mutexStat.Unlock(); | |
332 | } | |
333 | ||
334 | void StatMeter::CalcTotalStat(int* iUpTimeSec, int* iDnTimeSec, long long* iAllBytes, bool* bStandBy) | |
335 | { | |
336 | m_mutexStat.Lock(); | |
337 | if (m_tStartServer > 0) | |
338 | { | |
339 | *iUpTimeSec = (int)(time(NULL) - m_tStartServer); | |
340 | } | |
341 | else | |
342 | { | |
343 | *iUpTimeSec = 0; | |
344 | } | |
345 | *bStandBy = m_bStandBy; | |
346 | if (m_bStandBy) | |
347 | { | |
348 | *iDnTimeSec = (int)(m_tPausedFrom - m_tStartDownload); | |
349 | } | |
350 | else | |
351 | { | |
352 | *iDnTimeSec = (int)(time(NULL) - m_tStartDownload); | |
353 | } | |
354 | *iAllBytes = m_iAllBytes; | |
355 | m_mutexStat.Unlock(); | |
356 | } | |
357 | ||
358 | /* | |
359 | * NOTE: see note to "AddSpeedReading" | |
360 | */ | |
361 | int StatMeter::CalcCurrentDownloadSpeed() | |
362 | { | |
363 | if (m_bStandBy) | |
364 | { | |
365 | return 0; | |
366 | } | |
367 | ||
368 | int iTimeDiff = (int)time(NULL) - m_iSpeedStartTime * SPEEDMETER_SLOTSIZE; | |
369 | if (iTimeDiff == 0) | |
370 | { | |
371 | return 0; | |
372 | } | |
373 | ||
374 | return (int)(m_iSpeedTotalBytes / iTimeDiff); | |
375 | } | |
376 | ||
377 | void StatMeter::AddSpeedReading(int iBytes) | |
378 | { | |
379 | time_t tCurTime = time(NULL); | |
380 | int iNowSlot = (int)tCurTime / SPEEDMETER_SLOTSIZE; | |
381 | ||
382 | if (g_pOptions->GetAccurateRate()) | |
383 | { | |
384 | #ifdef HAVE_SPINLOCK | |
385 | m_spinlockSpeed.Lock(); | |
386 | #else | |
387 | m_mutexSpeed.Lock(); | |
388 | #endif | |
389 | } | |
390 | ||
391 | while (iNowSlot > m_iSpeedTime[m_iSpeedBytesIndex]) | |
392 | { | |
393 | //record bytes in next slot | |
394 | m_iSpeedBytesIndex++; | |
395 | if (m_iSpeedBytesIndex >= SPEEDMETER_SLOTS) | |
396 | { | |
397 | m_iSpeedBytesIndex = 0; | |
398 | } | |
399 | //Adjust counters with outgoing information. | |
400 | m_iSpeedTotalBytes = m_iSpeedTotalBytes - (long long)m_iSpeedBytes[m_iSpeedBytesIndex]; | |
401 | ||
402 | //Note we should really use the start time of the next slot | |
403 | //but its easier to just use the outgoing slot time. This | |
404 | //will result in a small error. | |
405 | m_iSpeedStartTime = m_iSpeedTime[m_iSpeedBytesIndex]; | |
406 | ||
407 | //Now reset. | |
408 | m_iSpeedBytes[m_iSpeedBytesIndex] = 0; | |
409 | m_iSpeedTime[m_iSpeedBytesIndex] = iNowSlot; | |
410 | } | |
411 | ||
412 | // Once per second recalculate summary field "m_iSpeedTotalBytes" to recover from possible synchronisation errors | |
413 | if (tCurTime > m_tSpeedCorrection) | |
414 | { | |
415 | long long iSpeedTotalBytes = 0; | |
416 | for (int i = 0; i < SPEEDMETER_SLOTS; i++) | |
417 | { | |
418 | iSpeedTotalBytes += m_iSpeedBytes[i]; | |
419 | } | |
420 | m_iSpeedTotalBytes = iSpeedTotalBytes; | |
421 | m_tSpeedCorrection = tCurTime; | |
422 | } | |
423 | ||
424 | if (m_iSpeedTotalBytes == 0) | |
425 | { | |
426 | m_iSpeedStartTime = iNowSlot; | |
427 | } | |
428 | m_iSpeedBytes[m_iSpeedBytesIndex] += iBytes; | |
429 | m_iSpeedTotalBytes += iBytes; | |
430 | m_iAllBytes += iBytes; | |
431 | ||
432 | if (g_pOptions->GetAccurateRate()) | |
433 | { | |
434 | #ifdef HAVE_SPINLOCK | |
435 | m_spinlockSpeed.Unlock(); | |
436 | #else | |
437 | m_mutexSpeed.Unlock(); | |
438 | #endif | |
439 | } | |
440 | } | |
441 | ||
442 | void StatMeter::ResetSpeedStat() | |
443 | { | |
444 | time_t tCurTime = time(NULL); | |
445 | m_iSpeedStartTime = (int)tCurTime / SPEEDMETER_SLOTSIZE; | |
446 | for (int i = 0; i < SPEEDMETER_SLOTS; i++) | |
447 | { | |
448 | m_iSpeedBytes[i] = 0; | |
449 | m_iSpeedTime[i] = m_iSpeedStartTime; | |
450 | } | |
451 | m_iSpeedBytesIndex = 0; | |
452 | m_iSpeedTotalBytes = 0; | |
453 | m_tSpeedCorrection = tCurTime; | |
454 | } | |
455 | ||
456 | void StatMeter::LogDebugInfo() | |
457 | { | |
458 | info(" ---------- SpeedMeter"); | |
459 | float fSpeed = (float)(CalcCurrentDownloadSpeed() / 1024.0); | |
460 | int iTimeDiff = (int)time(NULL) - m_iSpeedStartTime * SPEEDMETER_SLOTSIZE; | |
461 | info(" Speed: %f", fSpeed); | |
462 | info(" SpeedStartTime: %i", m_iSpeedStartTime); | |
463 | info(" SpeedTotalBytes: %i", m_iSpeedTotalBytes); | |
464 | info(" SpeedBytesIndex: %i", m_iSpeedBytesIndex); | |
465 | info(" AllBytes: %i", m_iAllBytes); | |
466 | info(" Time: %i", (int)time(NULL)); | |
467 | info(" TimeDiff: %i", iTimeDiff); | |
468 | for (int i=0; i < SPEEDMETER_SLOTS; i++) | |
469 | { | |
470 | info(" Bytes[%i]: %i, Time[%i]: %i", i, m_iSpeedBytes[i], i, m_iSpeedTime[i]); | |
471 | } | |
472 | ||
473 | m_mutexVolume.Lock(); | |
474 | int index = 0; | |
475 | for (ServerVolumes::iterator it = m_ServerVolumes.begin(); it != m_ServerVolumes.end(); it++, index++) | |
476 | { | |
477 | ServerVolume* pServerVolume = *it; | |
478 | info(" ServerVolume %i", index); | |
479 | pServerVolume->LogDebugInfo(); | |
480 | } | |
481 | m_mutexVolume.Unlock(); | |
482 | } | |
483 | ||
484 | void StatMeter::AddServerData(int iBytes, int iServerID) | |
485 | { | |
486 | if (iBytes == 0) | |
487 | { | |
488 | return; | |
489 | } | |
490 | ||
491 | m_mutexVolume.Lock(); | |
492 | m_ServerVolumes[0]->AddData(iBytes); | |
493 | m_ServerVolumes[iServerID]->AddData(iBytes); | |
494 | m_bStatChanged = true; | |
495 | m_mutexVolume.Unlock(); | |
496 | } | |
497 | ||
498 | ServerVolumes* StatMeter::LockServerVolumes() | |
499 | { | |
500 | m_mutexVolume.Lock(); | |
501 | ||
502 | // update slots | |
503 | for (ServerVolumes::iterator it = m_ServerVolumes.begin(); it != m_ServerVolumes.end(); it++) | |
504 | { | |
505 | ServerVolume* pServerVolume = *it; | |
506 | pServerVolume->AddData(0); | |
507 | } | |
508 | ||
509 | return &m_ServerVolumes; | |
510 | } | |
511 | ||
512 | void StatMeter::UnlockServerVolumes() | |
513 | { | |
514 | m_mutexVolume.Unlock(); | |
515 | } | |
516 | ||
517 | void StatMeter::Save() | |
518 | { | |
519 | if (!g_pOptions->GetServerMode()) | |
520 | { | |
521 | return; | |
522 | } | |
523 | ||
524 | m_mutexVolume.Lock(); | |
525 | g_pDiskState->SaveStats(g_pServerPool->GetServers(), &m_ServerVolumes); | |
526 | m_bStatChanged = false; | |
527 | m_mutexVolume.Unlock(); | |
528 | } | |
529 | ||
530 | bool StatMeter::Load(bool* pPerfectServerMatch) | |
531 | { | |
532 | m_mutexVolume.Lock(); | |
533 | ||
534 | bool bOK = g_pDiskState->LoadStats(g_pServerPool->GetServers(), &m_ServerVolumes, pPerfectServerMatch); | |
535 | ||
536 | for (ServerVolumes::iterator it = m_ServerVolumes.begin(); it != m_ServerVolumes.end(); it++) | |
537 | { | |
538 | ServerVolume* pServerVolume = *it; | |
539 | pServerVolume->CalcSlots(pServerVolume->GetDataTime() + g_pOptions->GetLocalTimeOffset()); | |
540 | } | |
541 | ||
542 | m_mutexVolume.Unlock(); | |
543 | ||
544 | return bOK; | |
545 | } |