1 // This file is part of BOINC.
2 // http://boinc.berkeley.edu
3 // Copyright (C) 2008 University of California
4 //
5 // BOINC is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License
7 // as published by the Free Software Foundation,
8 // either version 3 of the License, or (at your option) any later version.
9 //
10 // BOINC 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.
13 // See the GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
17 
18 #if defined(_WIN32) && !defined(__STDWX_H__) && !defined(_BOINC_WIN_) && !defined(_AFX_STDAFX_H_)
19 #include "boinc_win.h"
20 #endif
21 
22 #include "version.h"
23 #include "daemonmgt.h"
24 
version()25 void version(){
26     printf("boincsvcctrl, built from %s \n", PACKAGE_STRING );
27     exit(0);
28 }
29 
usage()30 void usage() {
31     fprintf(stderr, "\n\
32 usage: boincsvcctrl command\n\n\
33 Commands:\n\
34  --start                            start the BOINC service\n\
35  --stop                             stop the BOINC service\n\
36  --version, -V                      show core client version\n\
37 "
38 );
39     exit(1);
40 }
41 
main(int argc,char ** argv)42 int main(int argc, char** argv) {
43     int i = 1;
44     int retval = 0;
45 
46     if (argc < 1) {
47         usage();
48     }
49 
50     if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
51         usage();
52     }
53     if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V")) {
54         version();
55     }
56 
57     if (!strcmp(argv[i], "--start")) {
58         retval = !start_daemon();
59     }
60 
61     if (!strcmp(argv[i], "--stop")) {
62         retval = !stop_daemon();
63     }
64 
65     exit(retval);
66 }
67 
68