Debian Codegraph @

src/tools/davix_tool_mkcol_main.cpp

raw
1 /*
2 * This File is part of Davix, The IO library for HTTP based protocols
3 * Copyright (C) CERN 2013
4 * Author: Adrien Devresse <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #include <davix_internal.hpp>
23 #include <davix.hpp>
24 #include <tools/davix_tool_params.hpp>
25 #include <tools/davix_tool_util.hpp>
26 #include <cstdio>
27
28
29 // @author : Devresse Adrien
30 // main file for davix make collection cmd line tool
31
32
33 using namespace Davix;
34 using namespace std;
35
36 #define READ_BLOCK_SIZE 4096
37
38
39 const std::string scope_main = "Davix::Tools::davix-mkcol";
40
41
42
43 static std::string help_msg(const std::string & cmd_path){
44 std::string help_msg = fmt::format("Usage : {} ", cmd_path);
45 help_msg += Tool::get_base_description_options();
46 help_msg += Tool::get_common_options();
47
48 return help_msg;
49 }
50
51
52
53 int main(int argc, char** argv){
54 int retcode=-1;
55 Tool::OptParams opts;
56 DavixError* tmp_err=NULL;
57 opts.help_msg = help_msg(argv[0]);
58
59 if( (retcode= Tool::parse_davix_options(argc, argv, opts, &tmp_err)) ==0){
60 Context c;
61 if( (retcode = Tool::configureAuth(opts)) == 0){
62 if(checkProtocolSanity(opts, opts.vec_arg[0], &tmp_err)) {
63 configureContext(c, opts);
64 DavFile f(c,opts.vec_arg[0]);
65 f.makeCollection(&opts.params, &tmp_err);
66 if(tmp_err) retcode = -1;
67 }
68 }
69 }
70 Tool::errorPrint(&tmp_err);
71 return retcode;
72 }