~ubuntu-branches/ubuntu/oneiric/boinc/oneiric

« back to all changes in this revision

Viewing changes to client/log_flags.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2011-04-27 22:33:56 UTC
  • mfrom: (1.1.18 upstream) (6.2.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110427223356-2jyajtfxd5htgwsd
Tags: 6.12.26+dfsg-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#ifdef _WIN32
21
21
#include "boinc_win.h"
 
22
#ifdef _MSC_VER
 
23
#define chdir _chdir
 
24
#endif
22
25
#else
23
26
#include "config.h"
24
 
#endif
25
 
 
26
 
#ifndef _WIN32
27
27
#include <cstdio>
28
28
#include <cstring>
29
29
#include <unistd.h>
30
30
#endif
31
31
 
 
32
#include "common_defs.h"
 
33
#include "diagnostics.h"
32
34
#include "error_numbers.h"
33
 
#include "common_defs.h"
 
35
#include "filesys.h"
34
36
#include "parse.h"
35
37
#include "str_util.h"
36
 
#include "filesys.h"
37
38
 
38
39
#include "file_names.h"
39
40
#include "client_state.h"
46
47
CONFIG config;
47
48
 
48
49
LOG_FLAGS::LOG_FLAGS() {
 
50
    init();
 
51
}
 
52
 
 
53
void LOG_FLAGS::init() {
49
54
    memset(this, 0, sizeof(LOG_FLAGS));
50
55
    // on by default (others are off by default)
51
56
    //
62
67
 
63
68
    while (!xp.get(tag, sizeof(tag), is_tag)) {
64
69
        if (!is_tag) {
65
 
            msg_printf(NULL, MSG_USER_ERROR,
66
 
               "Unexpected text %s in %s", tag, CONFIG_FILE
 
70
            msg_printf_notice(NULL, false,
 
71
                "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=log_flags",
 
72
                "%s: %s",
 
73
                _("Unexpected text in cc_config.xml"),
 
74
                tag
67
75
            );
68
76
            continue;
69
77
        }
84
92
        if (xp.parse_bool(tag, "debt_debug", debt_debug)) continue;
85
93
        if (xp.parse_bool(tag, "std_debug", std_debug)) continue;
86
94
        if (xp.parse_bool(tag, "file_xfer_debug", file_xfer_debug)) continue;
87
 
        if (xp.parse_bool(tag, "guirpc_debug", guirpc_debug)) continue;
 
95
        if (xp.parse_bool(tag, "gui_rpc_debug", gui_rpc_debug)) continue;
 
96
        if (xp.parse_bool(tag, "heartbeat_debug", heartbeat_debug)) continue;
88
97
        if (xp.parse_bool(tag, "http_debug", http_debug)) continue;
89
98
        if (xp.parse_bool(tag, "http_xfer_debug", http_xfer_debug)) continue;
90
99
        if (xp.parse_bool(tag, "mem_usage_debug", mem_usage_debug)) continue;
101
110
        if (xp.parse_bool(tag, "time_debug", time_debug)) continue;
102
111
        if (xp.parse_bool(tag, "unparsed_xml", unparsed_xml)) continue;
103
112
        if (xp.parse_bool(tag, "work_fetch_debug", work_fetch_debug)) continue;
 
113
        if (xp.parse_bool(tag, "notice_debug", notice_debug)) continue;
104
114
 
105
 
        msg_printf(NULL, MSG_USER_ERROR, "Unrecognized tag in %s: <%s>\n",
106
 
            CONFIG_FILE, tag
 
115
        msg_printf_notice(NULL, false,
 
116
            "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=log_flags",
 
117
            "%s: <%s>",
 
118
            _("Unrecognized tag in cc_config.xml"),
 
119
            tag
107
120
        );
108
121
        xp.skip_unexpected(tag, true, "LOG_FLAGS::parse");
109
122
    }
143
156
    show_flag(buf, dcf_debug, "dcf_debug");
144
157
    show_flag(buf, debt_debug, "debt_debug");
145
158
    show_flag(buf, file_xfer_debug, "file_xfer_debug");
146
 
    show_flag(buf, guirpc_debug, "guirpc_debug");
 
159
    show_flag(buf, gui_rpc_debug, "gui_rpc_debug");
 
160
    show_flag(buf, heartbeat_debug, "heartbeat_debug");
147
161
    show_flag(buf, http_debug, "http_debug");
148
162
    show_flag(buf, http_xfer_debug, "http_xfer_debug");
149
163
    show_flag(buf, mem_usage_debug, "mem_usage_debug");
161
175
    show_flag(buf, time_debug, "time_debug");
162
176
    show_flag(buf, unparsed_xml, "unparsed_xml");
163
177
    show_flag(buf, work_fetch_debug, "work_fetch_debug");
 
178
    show_flag(buf, notice_debug, "notice_debug");
164
179
 
165
180
    if (strlen(buf)) {
166
181
        msg_printf(NULL, MSG_INFO, "log flags: %s", buf);
178
193
void CONFIG::show() {
179
194
    unsigned int i;
180
195
    if (ncpus>0) {
181
 
        msg_printf(NULL, MSG_INFO, "Config: use at most %d CPUs", config.ncpus);
 
196
        msg_printf(NULL, MSG_INFO, "Config: simulate %d CPUs", config.ncpus);
182
197
    }
183
198
    if (no_gpus) {
184
199
        msg_printf(NULL, MSG_INFO, "Config: don't use coprocessors");
185
200
    }
 
201
    if (no_info_fetch) {
 
202
        msg_printf(NULL, MSG_INFO, "Config: don't fetch project list or client version info");
 
203
    }
186
204
    if (no_priority_change) {
187
205
        msg_printf(NULL, MSG_INFO, "Config: run apps at regular priority");
188
206
    }
195
213
    if (zero_debts) {
196
214
        msg_printf(NULL, MSG_INFO, "Config: zero long-term debts on startup");
197
215
    }
 
216
    if (fetch_minimal_work) {
 
217
        msg_printf(NULL, MSG_INFO, "Config: fetch minimal work");
 
218
    }
198
219
    show_gpu_ignore(ignore_cuda_dev, "NVIDIA");
199
220
    show_gpu_ignore(ignore_ati_dev, "ATI");
200
221
    for (i=0; i<exclusive_apps.size(); i++) {
250
271
    dont_contact_ref_site = false;
251
272
    exclusive_apps.clear();
252
273
    exclusive_gpu_apps.clear();
 
274
    exit_after_finish = false;
 
275
    exit_when_idle = false;
 
276
    fetch_minimal_work = false;
253
277
    force_auth = "default";
254
278
    http_1_0 = false;
255
279
    ignore_cuda_dev.clear();
258
282
    max_file_xfers_per_project = MAX_FILE_XFERS_PER_PROJECT;
259
283
    max_stderr_file_size = 0;
260
284
    max_stdout_file_size = 0;
 
285
    max_tasks_reported = 0;
261
286
    ncpus = -1;
262
287
    network_test_url = "http://www.google.com/";
263
288
    no_alt_platform = false;
264
289
    no_gpus = false;
 
290
    no_info_fetch = false;
265
291
    no_priority_change = false;
266
292
    os_random_only = false;
267
293
    report_results_immediately = false;
268
294
    run_apps_manually = false;
269
295
    save_stats_days = 30;
270
296
    simple_gui_only = false;
 
297
    skip_cpu_benchmarks = false;
271
298
    start_delay = 0;
272
299
    stderr_head = false;
273
300
    suppress_net_info = false;
 
301
    unsigned_apps_ok = false;
274
302
    use_all_gpus = false;
275
303
    use_certs = false;
276
304
    use_certs_only = false;
279
307
 
280
308
int CONFIG::parse_options(XML_PARSER& xp) {
281
309
    char tag[1024], path[256];
282
 
    bool is_tag, btemp;
 
310
    bool is_tag;
283
311
    string s;
284
312
    int n;
285
313
 
296
324
 
297
325
    while (!xp.get(tag, sizeof(tag), is_tag)) {
298
326
        if (!is_tag) {
299
 
            msg_printf(NULL, MSG_USER_ERROR,
300
 
               "Unexpected text %s in %s", tag, CONFIG_FILE
 
327
            msg_printf_notice(NULL, false,
 
328
                "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
 
329
                "%s: %s",
 
330
                _("Unexpected text in cc_config.xml"),
 
331
                tag
301
332
            );
302
333
            continue;
303
334
        }
330
361
        if (xp.parse_bool(tag, "dont_check_file_sizes", dont_check_file_sizes)) continue;
331
362
        if (xp.parse_bool(tag, "dont_contact_ref_site", dont_contact_ref_site)) continue;
332
363
        if (xp.parse_string(tag, "exclusive_app", s)) {
333
 
            exclusive_apps.push_back(s);
 
364
            if (!strstr(s.c_str(), "boinc")) {
 
365
                exclusive_apps.push_back(s);
 
366
            }
334
367
            continue;
335
368
        }
336
369
        if (xp.parse_string(tag, "exclusive_gpu_app", s)) {
337
 
            exclusive_gpu_apps.push_back(s);
338
 
            continue;
339
 
        }
 
370
            if (!strstr(s.c_str(), "boinc")) {
 
371
                exclusive_gpu_apps.push_back(s);
 
372
            }
 
373
            continue;
 
374
        }
 
375
        if (xp.parse_bool(tag, "exit_after_finish", exit_after_finish)) continue;
 
376
        if (xp.parse_bool(tag, "exit_when_idle", exit_when_idle)) {
 
377
            if (exit_when_idle) {
 
378
                report_results_immediately = true;
 
379
            }
 
380
            continue;
 
381
        }
 
382
        if (xp.parse_bool(tag, "fetch_minimal_work", fetch_minimal_work)) continue;
340
383
        if (xp.parse_string(tag, "force_auth", force_auth)) {
341
384
            downcase_string(force_auth);
342
385
            continue;
354
397
        if (xp.parse_int(tag, "max_file_xfers_per_project", max_file_xfers_per_project)) continue;
355
398
        if (xp.parse_int(tag, "max_stderr_file_size", max_stderr_file_size)) continue;
356
399
        if (xp.parse_int(tag, "max_stdout_file_size", max_stdout_file_size)) continue;
 
400
        if (xp.parse_int(tag, "max_tasks_reported", max_tasks_reported)) continue;
357
401
        if (xp.parse_int(tag, "ncpus", ncpus)) continue;
358
402
        if (xp.parse_string(tag, "network_test_url", network_test_url)) {
359
403
            downcase_string(network_test_url);
361
405
        }
362
406
        if (xp.parse_bool(tag, "no_alt_platform", no_alt_platform)) continue;
363
407
        if (xp.parse_bool(tag, "no_gpus", no_gpus)) continue;
 
408
        if (xp.parse_bool(tag, "no_info_fetch", no_info_fetch)) continue;
364
409
        if (xp.parse_bool(tag, "no_priority_change", no_priority_change)) continue;
365
410
        if (xp.parse_bool(tag, "os_random_only", os_random_only)) continue;
366
411
#ifndef SIM
374
419
        if (xp.parse_bool(tag, "run_apps_manually", run_apps_manually)) continue;
375
420
        if (xp.parse_int(tag, "save_stats_days", save_stats_days)) continue;
376
421
        if (xp.parse_bool(tag, "simple_gui_only", simple_gui_only)) continue;
 
422
        if (xp.parse_bool(tag, "skip_cpu_benchmarks", skip_cpu_benchmarks)) continue;
377
423
        if (xp.parse_double(tag, "start_delay", start_delay)) continue;
378
424
        if (xp.parse_bool(tag, "stderr_head", stderr_head)) continue;
379
425
        if (xp.parse_bool(tag, "suppress_net_info", suppress_net_info)) continue;
 
426
        if (xp.parse_bool(tag, "unsigned_apps_ok", unsigned_apps_ok)) continue;
380
427
        if (xp.parse_bool(tag, "use_all_gpus", use_all_gpus)) continue;
381
428
        if (xp.parse_bool(tag, "use_certs", use_certs)) continue;
382
429
        if (xp.parse_bool(tag, "use_certs_only", use_certs_only)) continue;
383
430
        if (xp.parse_bool(tag, "zero_debts", zero_debts)) continue;
384
 
        if (xp.parse_bool(tag, "skip_cpu_benchmarks", btemp)) {
385
 
            gstate.skip_cpu_benchmarks = btemp;
386
 
            continue;
387
 
        }
388
 
        if (xp.parse_bool(tag, "unsigned_apps_ok", btemp)) {
389
 
            gstate.unsigned_apps_ok = btemp;
390
 
            continue;
391
 
        }
392
 
        if (xp.parse_bool(tag, "exit_after_finish", btemp)) {
393
 
            gstate.exit_after_finish = btemp;
394
 
            continue;
395
 
        }
396
431
 
397
 
        msg_printf(NULL, MSG_USER_ERROR, "Unrecognized tag in %s: <%s>\n",
398
 
            CONFIG_FILE, tag
 
432
        msg_printf_notice(NULL, false,
 
433
            "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
 
434
            "%s: <%s>",
 
435
            _("Unrecognized tag in cc_config.xml"),
 
436
            tag
399
437
        );
400
438
        xp.skip_unexpected(tag, true, "CONFIG::parse_options");
401
439
    }
410
448
 
411
449
    mf.init_file(f);
412
450
    if (!xp.parse_start("cc_config")) {
413
 
        msg_printf(NULL, MSG_USER_ERROR, "Missing start tag in %s", CONFIG_FILE);
 
451
        msg_printf_notice(NULL, false,
 
452
            "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
 
453
            "%s",
 
454
            _("Missing start tag in cc_config.xml")
 
455
        );
414
456
        return ERR_XML_PARSE;
415
457
    }
416
458
    while (!xp.get(tag, sizeof(tag), is_tag)) {
417
459
        if (!is_tag) {
418
 
            msg_printf(NULL, MSG_USER_ERROR,
419
 
               "Unexpected text %s in %s", tag, CONFIG_FILE
 
460
            msg_printf_notice(NULL, false,
 
461
                "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
 
462
                "%s: %s",
 
463
                _("Unexpected text in cc_config.xml"),
 
464
                tag
420
465
            );
421
466
            continue;
422
467
        }
429
474
            parse_options(xp);
430
475
            continue;
431
476
        }
432
 
        msg_printf(NULL, MSG_USER_ERROR, "Unparsed tag in %s: <%s>\n",
433
 
            CONFIG_FILE, tag
 
477
        if (!strcmp(tag, "options/")) continue;
 
478
        if (!strcmp(tag, "log_flags/")) continue;
 
479
        msg_printf_notice(NULL, false,
 
480
            "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
 
481
            "%s: <%s>",
 
482
            _("Unrecognized tag in cc_config.xml"),
 
483
            tag
434
484
        );
435
485
        xp.skip_unexpected(tag, true, "CONFIG.parse");
436
486
    }
437
 
    msg_printf(NULL, MSG_USER_ERROR, "Missing end tag in %s", CONFIG_FILE);
 
487
    msg_printf_notice(NULL, false,
 
488
        "http://boinc.berkeley.edu/manager_links.php?target=notice&controlid=config",
 
489
        "%s",
 
490
        _("Missing end tag in cc_config.xml")
 
491
    );
438
492
    return ERR_XML_PARSE;
439
493
}
440
494
 
444
498
    if (!init) {
445
499
        msg_printf(NULL, MSG_INFO, "Re-reading cc_config.xml");
446
500
        config.clear();
 
501
        log_flags.init();
447
502
    }
448
503
    f = boinc_fopen(CONFIG_FILE, "r");
449
504
    if (!f) return ERR_FOPEN;
450
 
    config.parse(f);
 
505
    int retval = config.parse(f);
451
506
    fclose(f);
 
507
    if (retval) return retval;
 
508
#ifndef SIM
 
509
    diagnostics_set_max_file_sizes(
 
510
        config.max_stdout_file_size, config.max_stderr_file_size
 
511
    );
 
512
#endif
452
513
    return 0;
453
514
}
454
515