~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to sched/census.cpp

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
// This info is used the feeder to decide how many shared-memory slots
21
21
// to devote to each HR class.
22
22
 
23
 
#include <stdio.h>
 
23
#include <cstdio>
24
24
 
25
25
#include "boinc_db.h"
26
26
#include "str_util.h"
28
28
#include "sched_util.h"
29
29
#include "sched_msgs.h"
30
30
#include "hr_info.h"
 
31
#include "svn_version.h"
31
32
 
32
 
void usage(char** argv) {
 
33
void usage(char *name) {
33
34
    fprintf(stderr,
34
35
        "This program scans the 'host' DB table and creates two files:\n\n"
35
36
        "%s: how much RAC each HR class is getting\n"
38
39
        "    (needed if you use the 'job_size_matching' scheduling option).\n\n"
39
40
        "This should be run as a periodic task (about once a day) from config.xml.\n"
40
41
        "For more info, see http://boinc.berkeley.edu/trac/wiki/HomogeneousRedundancy\n\n"
41
 
        "Usage: %s [--help]\n",
42
 
        HR_INFO_FILENAME, PERF_INFO_FILENAME, argv[0]
 
42
        "Usage: %s [OPTION]...\n\n"
 
43
        "Options:\n"
 
44
        "  -h --help     shows this help text.\n"
 
45
        "  -v --version  shows version information.\n",
 
46
        HR_INFO_FILENAME, PERF_INFO_FILENAME, name
43
47
    );
44
 
    exit(0);
45
48
}
46
49
 
47
50
int main(int argc, char** argv) {
48
51
    HR_INFO hri;
49
52
    int retval;
50
53
    
51
 
    for (int i=0; i<argc; i++) {
52
 
        if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
53
 
            usage(argv);
 
54
    for (int i=1; i<argc; i++) {
 
55
        if (is_arg(argv[i], "help") || is_arg(argv[i], "h")) {
 
56
            usage(argv[0]);
 
57
            exit(0);
 
58
        } else if (is_arg(argv[i], "version") || is_arg(argv[i], "v")) {
 
59
            printf("%s\n", SVN_VERSION);
 
60
            exit(0);
 
61
        } else {
 
62
            log_messages.printf(MSG_CRITICAL,
 
63
                "unknown command line argument: %s\n\n", argv[i]
 
64
            );
 
65
            usage(argv[0]);
 
66
            exit(1);
54
67
        }
55
68
    }
56
69
    check_stop_daemons();
57
 
    retval = config.parse_file("..");
 
70
    retval = config.parse_file();
58
71
    if (retval) {
59
72
        log_messages.printf(MSG_CRITICAL,
60
 
            "Can't parse ../config.xml: %s\n", boincerror(retval)
 
73
            "Can't parse config.xml: %s\n", boincerror(retval)
61
74
        );
62
75
        exit(1);
63
76
    }