blob: 435d0754cf4651358fe8f1fe237e10987171b009 [file] [log] [blame]
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
Zhenkai Zhub9f02082013-03-14 12:45:15 -07002VERSION='0.4'
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08003APPNAME='chronoshare'
4
Alexander Afanasyeve8496a32013-03-03 16:10:43 -08005from waflib import Build, Logs, Utils, Task, TaskGen, Configure
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08006
7def options(opt):
Zhenkai Zhua7e3da72012-12-27 13:45:00 -08008 opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
Alexander Afanasyev71b43e72012-12-27 01:03:43 -08009 opt.add_option('--yes',action='store_true',default=False) # for autoconf/automake/make compatibility
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080010 opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''')
Alexander Afanasyev5f9d09e2012-12-28 19:43:08 -080011
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080012 if Utils.unversioned_sys_platform () == "darwin":
Zhenkai Zhubb170d42013-02-25 13:48:59 -080013 opt.add_option('--auto-update', action='store_true',default=False,dest='autoupdate',help='''(OSX) Download sparkle framework and enable autoupdate feature''')
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080014
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070015 opt.load('compiler_c compiler_cxx boost protoc qt4 gnu_dirs')
16 opt.load('ndnx flags tinyxml', tooldir=['waf-tools'])
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080017
18def configure(conf):
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070019 conf.load("compiler_c compiler_cxx gnu_dirs flags")
Alexander Afanasyeva1b7bb52013-02-26 17:04:02 -080020
Alexander Afanasyevf2890632013-01-02 13:40:02 -080021 conf.define ("CHRONOSHARE_VERSION", VERSION)
22
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080023 conf.check_cfg(package='sqlite3', args=['--cflags', '--libs'], uselib_store='SQLITE3', mandatory=True)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080024 conf.check_cfg(package='libevent', args=['--cflags', '--libs'], uselib_store='LIBEVENT', mandatory=True)
25 conf.check_cfg(package='libevent_pthreads', args=['--cflags', '--libs'], uselib_store='LIBEVENT_PTHREADS', mandatory=True)
Zhenkai Zhu3457ed42013-03-12 15:15:21 -070026 conf.load('tinyxml')
27 conf.check_tinyxml(path=conf.options.tinyxml_dir)
Zhenkai Zhubc2f6282013-01-08 16:40:58 -080028
Alexander Afanasyevcf771142013-03-19 11:15:27 -070029 conf.define ("TRAY_ICON", "chronoshare-big.png")
30 if Utils.unversioned_sys_platform () == "linux":
31 conf.define ("TRAY_ICON", "chronoshare-ubuntu.png")
32
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -080033 if Utils.unversioned_sys_platform () == "darwin":
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080034 conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', mandatory=False, compile_filename='test.mm')
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080035 conf.check_cxx(framework_name='AppKit', uselib_store='OSX_APPKIT', mandatory=False, compile_filename='test.mm')
36 conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', define_name='HAVE_COREWLAN',
37 use="OSX_FOUNDATION", mandatory=False, compile_filename='test.mm')
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080038
39 if conf.options.autoupdate:
Zhenkai Zhubb170d42013-02-25 13:48:59 -080040 def check_sparkle(**kwargs):
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080041 conf.check_cxx (framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"],
Zhenkai Zhubb170d42013-02-25 13:48:59 -080042 uselib_store='OSX_SPARKLE', define_name='HAVE_SPARKLE', mandatory=True,
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080043 compile_filename='test.mm', use="OSX_FOUNDATION OSX_APPKIT",
Zhenkai Zhubb170d42013-02-25 13:48:59 -080044 **kwargs
45 )
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080046 try:
47 # Try standard paths first
Zhenkai Zhubb170d42013-02-25 13:48:59 -080048 check_sparkle()
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080049 except:
50 try:
51 # Try local path
52 Logs.info ("Check local version of Sparkle framework")
Alexander Afanasyev7c85d572013-02-26 22:06:54 -080053 check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(),
54 linkflags="-F%s/osx/Frameworks/" % conf.path.abspath())
55 conf.env.HAVE_LOCAL_SPARKLE = 1
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080056 except:
Alexander Afanasyeva1b7bb52013-02-26 17:04:02 -080057 import urllib, subprocess, os, shutil
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080058 if not os.path.exists('osx/Frameworks/Sparkle.framework'):
59 # Download to local path and retry
60 Logs.info ("Sparkle framework not found, trying to download it to 'build/'")
Alexander Afanasyeva1b7bb52013-02-26 17:04:02 -080061
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080062 urllib.urlretrieve ("http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip", "build/Sparkle.zip")
63 if os.path.exists('build/Sparkle.zip'):
64 try:
65 subprocess.check_call (['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle'])
66 os.remove ("build/Sparkle.zip")
67 if not os.path.exists("osx/Frameworks"):
68 os.mkdir ("osx/Frameworks")
69 os.rename ("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework")
70 shutil.rmtree("build/Sparkle", ignore_errors=True)
71
72 check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(),
73 linkflags="-F%s/osx/Frameworks/" % conf.path.abspath())
74 conf.env.HAVE_LOCAL_SPARKLE = 1
75 except subprocess.CalledProcessError as e:
76 conf.fatal("Cannot find Sparkle framework. Auto download failed: '%s' returned %s" % (' '.join(e.cmd), e.returncode))
77 except:
78 conf.fatal("Unknown Error happened when auto downloading Sparkle framework")
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080079
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080080 if conf.is_defined('HAVE_SPARKLE'):
81 conf.env.HAVE_SPARKLE = 1 # small cheat for wscript
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -080082
Alexander Afanasyevc507ac22013-01-21 16:01:58 -080083 if conf.options.log4cxx:
84 conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
85 conf.define ("HAVE_LOG4CXX", 1)
86
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070087 conf.load ('ndnx')
Alexander Afanasyev33206982013-01-09 16:29:29 -080088
89 conf.load('protoc')
Alexander Afanasyev33206982013-01-09 16:29:29 -080090
91 conf.load('qt4')
92
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080093 conf.load('boost')
94
Alexander Afanasyeve1c95042013-02-27 01:02:36 -080095 conf.check_boost(lib='system test iostreams filesystem regex thread date_time')
Zhenkai Zhua7e3da72012-12-27 13:45:00 -080096
Alexander Afanasyev71b43e72012-12-27 01:03:43 -080097 boost_version = conf.env.BOOST_VERSION.split('_')
98 if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
99 Logs.error ("Minumum required boost version is 1.46")
100 return
101
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700102 conf.check_ndnx ()
103 conf.check_openssl ()
104 conf.define ('NDNX_PATH', conf.env.NDNX_ROOT)
Zhenkai Zhua7e3da72012-12-27 13:45:00 -0800105
Zhenkai Zhua7e3da72012-12-27 13:45:00 -0800106 if conf.options._test:
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -0800107 conf.define ('_TESTS', 1)
Alexander Afanasyev72ac2192013-01-03 19:33:43 -0800108 conf.env.TEST = 1
Zhenkai Zhua7e3da72012-12-27 13:45:00 -0800109
Alexander Afanasyev71b43e72012-12-27 01:03:43 -0800110 conf.write_config_header('src/config.h')
111
Zhenkai Zhua7e3da72012-12-27 13:45:00 -0800112def build (bld):
Zhenkai Zhue8409422013-01-28 12:52:17 -0800113 executor = bld.objects (
114 target = "executor",
115 features = ["cxx"],
116 source = bld.path.ant_glob(['executor/**/*.cc']),
117 use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX',
118 includes = "executor src",
119 )
120
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -0800121 scheduler = bld.objects (
122 target = "scheduler",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -0800123 features = ["cxx"],
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -0800124 source = bld.path.ant_glob(['scheduler/**/*.cc']),
Zhenkai Zhue8409422013-01-28 12:52:17 -0800125 use = 'BOOST BOOST_THREAD LIBEVENT LIBEVENT_PTHREADS LOG4CXX executor',
Zhenkai Zhu1888f742013-01-28 12:47:33 -0800126 includes = "scheduler executor src",
Alexander Afanasyev68f2a952013-01-08 14:34:16 -0800127 )
128
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700129 libndnx = bld (
130 target="ndnx",
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -0800131 features=['cxx'],
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700132 source = bld.path.ant_glob(['ndnx/**/*.cc', 'ndnx/**/*.cpp']),
133 use = 'TINYXML BOOST BOOST_THREAD SSL NDNX LOG4CXX scheduler executor',
134 includes = "ndnx src scheduler executor",
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800135 )
136
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800137 adhoc = bld (
138 target = "adhoc",
139 features=['cxx'],
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700140 includes = "ndnx src",
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800141 )
142 if Utils.unversioned_sys_platform () == "darwin":
143 adhoc.mac_app = True
144 adhoc.source = 'adhoc/adhoc-osx.mm'
Alexander Afanasyev02a86ec2013-03-04 13:09:31 -0800145 adhoc.use = "BOOST BOOST_THREAD BOOST_DATE_TIME LOG4CXX OSX_FOUNDATION OSX_COREWLAN"
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800146
Alexander Afanasyev3f101ec2013-01-17 16:58:03 -0800147 chornoshare = bld (
148 target="chronoshare",
149 features=['cxx'],
150 source = bld.path.ant_glob(['src/**/*.cc', 'src/**/*.cpp', 'src/**/*.proto']),
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700151 use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 LOG4CXX scheduler ndnx",
152 includes = "ndnx scheduler src executor",
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800153 )
Alexander Afanasyevb2fe74e2013-01-20 16:06:43 -0800154
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800155 fs_watcher = bld (
156 target = "fs_watcher",
157 features = "qt4 cxx",
158 defines = "WAF",
159 source = bld.path.ant_glob(['fs-watcher/*.cc']),
160 use = "SQLITE3 LOG4CXX scheduler executor QTCORE",
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700161 includes = "ndnx fs-watcher scheduler executor src",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800162 )
163
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800164 # Unit tests
165 if bld.env['TEST']:
166 unittests = bld.program (
167 target="unit-tests",
Zhenkai Zhud1756272013-02-01 17:02:18 -0800168 features = "qt4 cxx cxxprogram",
169 defines = "WAF",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800170 source = bld.path.ant_glob(['test/*.cc']),
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700171 use = 'BOOST_TEST BOOST_FILESYSTEM BOOST_DATE_TIME LOG4CXX SQLITE3 QTCORE QTGUI ndnx database fs_watcher chronoshare',
172 includes = "ndnx scheduler src executor gui fs-watcher",
Alexander Afanasyev4f62f442013-02-07 22:36:08 -0800173 install_prefix = None,
Alexander Afanasyevee7e6132013-01-03 20:03:14 -0800174 )
Alexander Afanasyevf2890632013-01-02 13:40:02 -0800175
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -0800176 http_server = bld (
177 target = "http_server",
Zhenkai Zhud9429222013-02-25 22:34:09 -0800178 features = "qt4 cxx",
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -0800179 source = bld.path.ant_glob(['server/*.cpp']),
Zhenkai Zhud9429222013-02-25 22:34:09 -0800180 includes = "server src .",
181 use = "BOOST QTCORE"
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -0800182 )
183
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800184 qt = bld (
185 target = "ChronoShare",
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800186 features = "qt4 cxx cxxprogram html_resources",
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800187 defines = "WAF",
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800188 source = bld.path.ant_glob(['gui/*.cpp', 'gui/*.cc', 'gui/images.qrc']),
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700189 includes = "ndnx scheduler executor fs-watcher gui src adhoc server . ",
190 use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ndnx database chronoshare http_server",
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800191
192 html_resources = bld.path.find_dir ("gui/html").ant_glob([
193 '**/*.js', '**/*.png', '**/*.css',
194 '**/*.html', '**/*.gif', '**/*.ico'
195 ]),
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800196 )
197
198 if Utils.unversioned_sys_platform () == "darwin":
199 app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800200<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
201<plist version="0.9">
202<dict>
203 <key>CFBundlePackageType</key>
204 <string>APPL</string>
Zhenkai Zhud5d311a2013-03-04 15:12:46 -0800205 <key>CFBundleIconFile</key>
206 <string>chronoshare.icns</string>
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800207 <key>CFBundleGetInfoString</key>
208 <string>Created by Waf</string>
Zhenkai Zhu3857d712013-02-27 22:51:25 -0800209 <key>CFBundleIdentifier</key>
210 <string>edu.ucla.cs.irl.Chronoshare</string>
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800211 <key>CFBundleSignature</key>
212 <string>????</string>
213 <key>NOTE</key>
214 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
215 <key>CFBundleExecutable</key>
216 <string>%s</string>
217 <key>LSUIElement</key>
218 <string>1</string>
Zhenkai Zhu8e3e9072013-02-28 15:40:51 -0800219 <key>SUPublicDSAKeyFile</key>
220 <string>dsa_pub.pem</string>
Zhenkai Zhud5d311a2013-03-04 15:12:46 -0800221 <key>CFBundleIconFile</key>
222 <string>chronoshare.icns</string>
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800223</dict>
224</plist>'''
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800225 qt.mac_app = "ChronoShare.app"
226 qt.mac_plist = app_plist % "ChronoShare"
Zhenkai Zhud5d311a2013-03-04 15:12:46 -0800227 qt.mac_resources = 'chronoshare.icns'
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800228 qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800229
Alexander Afanasyev5a95a252013-02-25 12:55:48 -0800230 if bld.env['HAVE_SPARKLE']:
231 qt.use += " OSX_SPARKLE"
232 qt.source += ["osx/auto-update/sparkle-auto-update.mm"]
233 qt.includes += " osx/auto-update"
Alexander Afanasyev7c85d572013-02-26 22:06:54 -0800234 if bld.env['HAVE_LOCAL_SPARKLE']:
235 qt.mac_frameworks = "osx/Frameworks/Sparkle.framework"
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800236
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700237 if Utils.unversioned_sys_platform () == "linux":
238 bld (
239 features = "process_in",
240 target = "ChronoShare.desktop",
241 source = "ChronoShare.desktop.in",
242 install_prefix = "${DATADIR}/applications",
243 )
244 bld.install_files ("${DATADIR}/applications", "ChronoShare.desktop")
245 bld.install_files ("${DATADIR}/ChronoShare", "gui/images/chronoshare-big.png")
246
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800247 cmdline = bld (
248 target = "csd",
249 features = "qt4 cxx cxxprogram",
250 defines = "WAF",
Zhenkai Zhu369eff12013-02-05 15:43:49 -0800251 source = "cmd/csd.cc",
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700252 includes = "ndnx scheduler executor gui fs-watcher src . ",
253 use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX fs_watcher ndnx database chronoshare"
Alexander Afanasyev548d38d2013-01-26 16:36:06 -0800254 )
255
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800256 dump_db = bld (
257 target = "dump-db",
258 features = "cxx cxxprogram",
259 source = "cmd/dump-db.cc",
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -0700260 includes = "ndnx scheduler executor gui fs-watcher src . ",
261 use = "BOOST BOOST_FILESYSTEM BOOST_DATE_TIME SQLITE3 QTCORE LOG4CXX fs_watcher ndnx database chronoshare"
Alexander Afanasyeveb575e02013-01-26 17:14:51 -0800262 )
263
Alexander Afanasyeva98e69c2013-02-24 15:42:45 -0800264from waflib import TaskGen
265@TaskGen.extension('.mm')
266def m_hook(self, node):
267 """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
268 return self.create_compiled_task('cxx', node)
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800269
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700270@TaskGen.extension('.js', '.png', '.css', '.html', '.gif', '.ico', '.in')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800271def sig_hook(self, node):
272 node.sig=Utils.h_file (node.abspath())
Zhenkai Zhu6b53f932013-03-02 20:46:02 -0800273
Alexander Afanasyev0b38ad02013-03-19 13:42:22 -0700274@TaskGen.feature('process_in')
275@TaskGen.after_method('process_source')
276def create_process_in(self):
277 dst = self.bld.path.find_or_declare (self.target)
278 tsk = self.create_task ('process_in', self.source, dst)
279
280class process_in(Task.Task):
281 color='PINK'
282
283 def run (self):
284 self.outputs[0].write (Utils.subst_vars(self.inputs[0].read (), self.env))
285
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800286@TaskGen.feature('html_resources')
287@TaskGen.before_method('process_source')
288def create_qrc_task(self):
289 output = self.bld.path.find_or_declare ("gui/html.qrc")
290 tsk = self.create_task('html_resources', self.html_resources, output)
Alexander Afanasyev1cb641f2013-03-03 17:49:02 -0800291 tsk.base_path = output.parent.get_src ()
292 self.create_rcc_task (output.get_src ())
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800293
294class html_resources(Task.Task):
295 color='PINK'
296
297 def __str__ (self):
Alexander Afanasyev1cb641f2013-03-03 17:49:02 -0800298 return "%s: Generating %s\n" % (self.__class__.__name__.replace('_task',''), self.outputs[0].nice_path ())
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800299
300 def run (self):
301 out = self.outputs[0]
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800302 bld_out = out.get_bld ()
303 src_out = out.get_src ()
304 bld_out.write('<RCC>\n <qresource prefix="/">\n')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800305 for f in self.inputs:
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800306 bld_out.write (' <file>%s</file>\n' % f.path_from (self.base_path), 'a')
307 bld_out.write(' </qresource>\n</RCC>', 'a')
Alexander Afanasyev1cb641f2013-03-03 17:49:02 -0800308
Alexander Afanasyev9cc6c212013-03-04 12:45:38 -0800309 src_out.write (bld_out.read(), 'w')
Alexander Afanasyevcaf48e22013-03-02 22:47:32 -0800310 return 0