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

« back to all changes in this revision

Viewing changes to client/cs_account.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:
15
15
// You should have received a copy of the GNU Lesser General Public License
16
16
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
17
17
 
 
18
#include "cpp.h"
 
19
 
18
20
#ifdef _WIN32
19
21
#include "boinc_win.h"
20
 
#endif
21
 
 
22
 
#ifndef _WIN32
 
22
#else
23
23
#include "config.h"
24
24
#include <algorithm>
25
25
#include <cstdio>
 
26
#include <cstdlib>
 
27
#include <cstring>
26
28
#include <cassert>
27
29
#ifdef HAVE_SYS_STAT_H
28
30
#include <sys/stat.h>
29
31
#endif
30
32
#endif
31
33
 
32
 
#include <algorithm>
33
 
#include <cstring>
34
34
#include "filesys.h"
35
35
#include "parse.h"
36
36
#include "str_util.h"
 
37
#include "url.h"
 
38
#include "str_replace.h"
37
39
#include "client_state.h"
38
40
#include "client_msgs.h"
39
41
#include "log_flags.h"
41
43
#include "file_names.h"
42
44
 
43
45
using std::string;
 
46
using std::sort;
44
47
 
45
48
// write account_*.xml file.
46
49
// NOTE: this is called only when
89
92
    char buf[256];
90
93
    int retval;
91
94
    bool in_project_prefs = false;
 
95
    no_cpu_pref = false;
 
96
    no_cuda_pref = false;
 
97
    no_ati_pref = false;
92
98
 
93
99
    strcpy(master_url, "");
94
100
    strcpy(authenticator, "");
114
120
            continue;
115
121
        } else if (parse_str(buf, "<authenticator>", authenticator, sizeof(authenticator))) continue;
116
122
        else if (parse_double(buf, "<resource_share>", resource_share)) continue;
 
123
        else if (parse_bool(buf, "no_cpu", no_cpu_pref)) continue;
 
124
        else if (parse_bool(buf, "no_cuda", no_cuda_pref)) continue;
 
125
        else if (parse_bool(buf, "no_ati", no_ati_pref)) continue;
117
126
        else if (parse_str(buf, "<project_name>", project_name, sizeof(project_name))) continue;
118
127
        else if (match_tag(buf, "<gui_urls>")) {
119
128
            string foo;
166
175
            if (!strcmp(venue, host_venue)) {
167
176
                using_venue_specific_prefs = true;
168
177
                in_right_venue = true;
 
178
                no_cpu_pref = false;    // reset these
 
179
                no_cuda_pref = false;
 
180
                no_ati_pref = false;
169
181
            } else {
170
182
                std::string devnull;
171
183
                retval = copy_element_contents(in, "</venue>", devnull);
187
199
            continue;
188
200
        } else if (parse_double(buf, "<resource_share>", resource_share)) {
189
201
            continue;
190
 
        } else {
 
202
        }
 
203
        else if (parse_bool(buf, "no_cpu", no_cpu_pref)) continue;
 
204
        else if (parse_bool(buf, "no_cuda", no_cuda_pref)) continue;
 
205
        else if (parse_bool(buf, "no_ati", no_ati_pref)) continue;
 
206
        else {
191
207
            if (log_flags.unparsed_xml) {
192
208
                msg_printf(0, MSG_INFO,
193
209
                    "[unparsed_xml] parse_account_file_venue(): unrecognized: %s\n", buf
247
263
        retval = project->parse_account(f);
248
264
        fclose(f);
249
265
        if (retval) {
250
 
            msg_printf(NULL, MSG_INTERNAL_ERROR,
 
266
            msg_printf(project, MSG_INTERNAL_ERROR,
251
267
                "Couldn't parse account file %s", name.c_str()
252
268
            );
253
269
            delete project;
254
270
        } else {
255
271
            if (lookup_project(project->master_url)) {
256
 
                msg_printf(NULL, MSG_INFO,
 
272
                msg_printf(project, MSG_INFO,
257
273
                    "Duplicate account file %s - ignoring", name.c_str()
258
274
                );
259
275
                delete project;
421
437
    strip_whitespace(canonical_master_url);
422
438
    canonicalize_master_url(canonical_master_url);
423
439
    if (!valid_master_url(canonical_master_url)) {
424
 
        msg_printf(0, MSG_USER_ERROR, "Invalid URL: %s", canonical_master_url);
 
440
        msg_printf(0, MSG_INFO, "Invalid URL: %s", canonical_master_url);
425
441
        return ERR_INVALID_URL;
426
442
    }
427
443
 
428
444
    safe_strcpy(auth, _auth);
429
445
    strip_whitespace(auth);
430
446
    if (!strlen(auth)) {
431
 
        msg_printf(0, MSG_USER_ERROR, "Missing account key");
 
447
        msg_printf(0, MSG_INFO, "Missing account key");
432
448
        return ERR_AUTHENTICATOR;
433
449
    }
434
450
 
435
451
    // check if we're already attached to this project
436
452
    //
437
453
    if (lookup_project(canonical_master_url)) {
438
 
        msg_printf(0, MSG_USER_ERROR, "Already attached to %s", canonical_master_url);
 
454
        msg_printf(0, MSG_INFO, "Already attached to %s", canonical_master_url);
439
455
        return ERR_ALREADY_ATTACHED;
440
456
    }
441
457
 
491
507
    return 0;
492
508
}
493
509
 
494
 
const char *BOINC_RCSID_497223a3f8 = "$Id: cs_account.cpp 16150 2008-10-07 12:45:06Z davea $";