blob: 2ad4d0d0abedaf76975cb7141a4a016cfef9feee [file] [log] [blame]
Alexander Afanasyev548d38d2013-01-26 16:36:06 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 University of California, Los Angeles
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 version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#include "dispatcher.h"
22#include "fs-watcher.h"
23#include "logging.h"
24#include "ccnx-wrapper.h"
25
26#include <boost/make_shared.hpp>
27
28using namespace boost;
29using namespace std;
30using namespace Ccnx;
31
32int main(int argc, char *argv[])
33{
34 INIT_LOGGERS ();
35
36 if (argc != 4)
37 {
38 cerr << "Usage: ./csd <username> <shared-folder> <path>" << endl;
39 return 1;
40 }
41
42 string username = argv[1];
43 string sharedFolder = argv[2];
44 string path = argv[3];
45
46 cout << "Starting ChronoShare for [" << username << "] shared-folder [" << sharedFolder << "] at [" << path << "]" << endl;
47
48 Dispatcher dispatcher (username, sharedFolder, path, make_shared<CcnxWrapper> ());
49
50 FsWatcher watcher (path.c_str (),
51 bind (&Dispatcher::Did_LocalFile_AddOrModify, &dispatcher, _1),
52 bind (&Dispatcher::Did_LocalFile_Delete, &dispatcher, _1));
53
54 while (true)
55 {
56 sleep (1);
57 }
58
59 return 0;
60}