-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboxapi.c
More file actions
733 lines (611 loc) · 18.2 KB
/
boxapi.c
File metadata and controls
733 lines (611 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
/***************************************
DR: Interazione con il sito
This software is licensed under the
GPLv2 license.
***************************************/
#include "boxapi.h"
#include "boxpath.h"
#include "boxhttp.h"
#include "boxopts.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <libgen.h>
#include <termios.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
#include <time.h>
#include <pthread.h>
#include <sys/stat.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/uri.h>
/* Building blocks for OpenBox api endpoints
and return codes
*/
#define API_KEY_VAL "2uc9ec1gtlyaszba4h6nixt7gyzq3xir"
#define API_KEY "&api_key=" API_KEY_VAL
#define API_TOKEN API_KEY "&auth_token="
#define API_REST_BASE "://www.box.net/api/1.0/rest?action="
#define API_GET_TICKET API_REST_BASE "get_ticket" API_KEY
#define API_GET_TICKET_OK "get_ticket_ok"
#define API_LOGIN_URL "https://www.box.net/api/1.0/auth/"
#define API_GET_AUTH_TOKEN API_REST_BASE "get_auth_token" API_KEY
#define API_GET_AUTH_TOKEN_OK "get_auth_token_ok"
//#define API_GET_ACCOUNT_TREE API_REST_BASE "get_account_tree¶ms%%5B%%5D=nozip&folder_id=0" \
// API_TOKEN
#define API_GET_ACCOUNT_TREE API_REST_BASE "get_account_tree&folder_id=0" API_TOKEN
#define API_GET_ACCOUNT_TREE_OK "listing_ok"
#define API_DOWNLOAD "://www.box.net/api/1.0/download/"
#define API_UPLOAD "://upload.box.net/api/1.0/upload/"
#define API_CREATE_DIR API_REST_BASE "create_folder" API_TOKEN
#define API_CREATE_DIR_OK "create_ok"
#define API_RENAME API_REST_BASE "rename" API_TOKEN
#define API_RENAME_OK "s_rename_node"
#define API_MOVE API_REST_BASE "move" API_TOKEN
#define API_MOVE_OK "s_move_node"
#define API_UNLINK API_REST_BASE "delete&target=file" API_TOKEN
#define API_UNLINK_OK "s_delete_node"
#define API_RMDIR API_REST_BASE "delete&target=folder" API_TOKEN
#define API_RMDIR_OK API_UNLINK_OK
#define API_LOGOUT API_REST_BASE "logout" API_KEY "&auth_token="
#define LOCKDIR(dir) pthread_mutex_lock(dir->dirmux);
#define UNLOCKDIR(dir) pthread_mutex_unlock(dir->dirmux);
/* globals, written during initialization */
char *ticket = NULL, *auth_token = NULL;
char treefile[] = "/tmp/boxXXXXXX";
long tot_space, used_space;
struct box_options_t options;
char * proto = PROTO_HTTP;
off_t filesize(const char * localpath)
{
struct stat sb;
stat(localpath, &sb);
return sb.st_size;
}
char * tag_value(const char * buf, const char * tag)
{
char * tmp;
char * sp, * ep;
sp = strstr(buf,tag)+strlen(tag)+1;
ep = strstr(sp,"<");
tmp =malloc(ep-sp+1);
strncpy(tmp, sp, ep-sp);
tmp[ep-sp]=0;
return tmp;
}
long tag_lvalue(const char * buf, const char * tag)
{
char * tmp;
long rv;
tmp = tag_value(buf, tag);
rv = atol(tmp);
free(tmp);
return rv;
}
char * attr_value(const char * buf, const char * attr)
{
char * tmp;
char * sp, * ep;
char ss[24];
sprintf(ss,"%s=\"", attr);
sp = strstr(buf,ss);// +strlen(ss);
if(!sp) return NULL;
else sp = sp + strlen(ss);
ep = strstr(sp,"\"");
tmp =malloc(ep-sp+1);
strncpy(tmp, sp, ep-sp);
tmp[ep-sp]=0;
return tmp;
}
int ends_with(const char * str, const char * suff)
{
char * sub = strstr(str, suff);
if(!sub) return FALSE;
return !strcmp(suff, sub);
}
void api_logout()
{
char * buf;
buf = http_fetchf("%s" API_LOGOUT "%s", proto, auth_token);
free(buf);
}
void api_free()
{
api_logout();
if(ticket) free(ticket);
if(auth_token) free(auth_token);
syslog(LOG_INFO, "Unmounting filesystem");
closelog();
xmlCleanupParser();
if(allDirs) xmlHashFree(allDirs, NULL); // TODO: Deallocator!
}
/* only for 1st level nodes! */
char * node_value(const char * buf, const char * name)
{
char * val = NULL;
xmlDoc *doc = NULL;
xmlNode *root_element = NULL;
xmlNode *cur_node = NULL;
doc = xmlReadDoc(buf, "noname.xml",NULL, 0);
root_element = xmlDocGetRootElement(doc);
for(cur_node = root_element->children; cur_node && !val; cur_node = cur_node->next) {
if (cur_node->type == XML_ELEMENT_NODE) {
if(!strcmp(name,cur_node->name)) {
// a nice thing of text nodes :(((
val = (cur_node->content ? strdup(cur_node->content) :
strdup(cur_node->children->content));
}
}
}
xmlFreeDoc(doc);
return val;
}
int get_ticket(struct box_options_t* options) {
char * buf = NULL;
char * status = NULL;
int res = 0;
postdata_t postpar=post_init();
char gkurl[512];
buf = http_fetchf("%s" API_GET_TICKET, proto);
status = node_value(buf,"status");
if(strcmp(status,API_GET_TICKET_OK)) {
res = 1;
}
if(!res) ticket = node_value(buf,"ticket");
if(buf) free(buf);
if(status) free(status);
/* autologin using http POST */
post_add(postpar,"dologin","1");
post_add(postpar,"__login","1");
post_add(postpar,"login",options->user);
post_add(postpar,"password",options->password);
sprintf(gkurl, API_LOGIN_URL "%s",ticket);
http_post(gkurl,postpar);
post_free(postpar);
return res;
}
void api_getusage(long * tot_sp, long * used_sp)
{
*tot_sp = tot_space;
*used_sp = used_space;
}
int api_createdir(const char * path)
{
int res = 0;
boxpath * bpath;
boxdir *newdir;
boxfile * aFile;
char * dirid, *buf, *status;
bpath = boxpath_from_string(path);
if(bpath->dir) {
//syslog(LOG_WARNING, "creating dir %s (escaped: %s) ",base,xmlURIEscapeStr(base,""));
buf = http_fetchf("%s" API_CREATE_DIR "%s&parent_id=%s&name=%s&share=0",
proto, auth_token, bpath->dir->id, xmlURIEscapeStr(bpath->base,""));
status = node_value(buf,"status");
if(strcmp(status,API_CREATE_DIR_OK)) {
res = -EINVAL;
free(buf); free(status);
boxpath_free(bpath);
return res;
}
free(status);
dirid = tag_value(buf,"folder_id");
free(buf);
// aggiungo 1 entry all'hash
newdir = boxdir_create();
newdir->id = dirid;
xmlHashAddEntry(allDirs, path, newdir);
// upd parent
aFile = boxfile_create(bpath->base);
aFile->id = strdup(dirid);
LOCKDIR(bpath->dir);
list_append(bpath->dir->folders, aFile);
UNLOCKDIR(bpath->dir);
} else {
syslog(LOG_WARNING, "UH oh... wrong path %s",path);
res = -EINVAL;
}
boxpath_free(bpath);
return res;
}
int api_create(const char * path)
{
int res = 0;
boxpath * bpath = boxpath_from_string(path);
boxfile * aFile;
if(bpath->dir) {
aFile = boxfile_create(bpath->base);
LOCKDIR(bpath->dir);
list_append(bpath->dir->files,aFile);
UNLOCKDIR(bpath->dir);
} else {
syslog(LOG_WARNING, "UH oh... wrong path %s",path);
res = -ENOTDIR;
}
boxpath_free(bpath);
return res;
}
int get_key() {
int res = 0;
char * buf = NULL;
char * status = NULL;
buf = http_fetchf("%s" API_GET_AUTH_TOKEN "&ticket=%s", proto, ticket);
status = node_value(buf,"status");
if(strcmp(status,API_GET_AUTH_TOKEN_OK)) {
res = 1;
}
if(!res) {
auth_token = node_value(buf,"auth_token");
tot_space = tag_lvalue(buf,"space_amount");
used_space = tag_lvalue(buf,"space_used");
}
if(buf) free(buf);
if(status) free(status);
return res;
}
int get_tree() {
int res = 0;
int fd;
char gkurl[512];
sprintf(gkurl, "%s" API_GET_ACCOUNT_TREE "%s", proto, auth_token);
fd = mkstemp(treefile);
if(fd!=-1) close(fd);
res = http_fetch_file(gkurl, treefile, FALSE);
return res;
}
void set_filedata(const boxpath * bpath, char * fid, long fsize)
{
boxfile * aFile;
list_iter it = list_get_iter(bpath->dir->files);
for(; it; it = list_iter_next(it)) {
aFile = (boxfile*)list_iter_getval(it);
if(!strcmp(aFile->name, bpath->base)) {
aFile->id = fid;
aFile->size = fsize;
return;
}
}
}
int api_open(const char * path, const char * pfile){
int res = 0;
char gkurl[512]="";
boxfile * aFile;
list_iter it;
boxpath * bpath = boxpath_from_string(path);
if(!boxpath_getfile(bpath)) res = -ENOENT;
if(!res) {
sprintf(gkurl, "%s" API_DOWNLOAD "%s/%s", proto, auth_token, bpath->file->id);
res = http_fetch_file(gkurl, pfile, FALSE);
//NOTE: we could check for bpath->file->size > PART_LEN, but
//checking filesize is more robust, since PART_LEN may change in
//future, or become configurable.
if(!res && options.splitfiles && bpath->file->size > filesize(pfile)) {
//download of other parts
for(it = boxpath_first_part(bpath); it ; it=boxpath_next_part(bpath, it)) {
aFile = (boxfile*) list_iter_getval(it);
sprintf(gkurl, "%s" API_DOWNLOAD "%s/%s", proto, auth_token, aFile->id);
if(options.verbose) syslog(LOG_DEBUG, "Appending file part %s", aFile->name);
http_fetch_file(gkurl, pfile, TRUE);
}
}
}
boxpath_free(bpath);
return res;
}
int api_readdir(const char * path, fuse_fill_dir_t filler, void * buf)
{
int res = 0;
boxdir * dir;
boxfile * aFile;
list_iter it;
dir = (boxdir *) xmlHashLookup(allDirs,path);
if (dir==NULL) return -EINVAL;
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
LOCKDIR(dir);
for(it=list_get_iter(dir->folders); it; it = list_iter_next(it)) {
aFile = (boxfile*)list_iter_getval(it);
filler(buf, aFile->name, NULL, 0);
}
for(it=list_get_iter(dir->files); it; it = list_iter_next(it)) {
aFile = (boxfile*)list_iter_getval(it);
filler(buf, aFile->name, NULL, 0);
}
UNLOCKDIR(dir);
return res;
}
int api_subdirs(const char * path)
{
boxdir * dir;
dir = (boxdir *) xmlHashLookup(allDirs,path);
if (dir==NULL) return -1;
return list_size(dir->folders);
}
int api_getattr(const char *path, struct stat *stbuf)
{
memset(stbuf, 0, sizeof(struct stat));
boxpath * bpath = boxpath_from_string(path);
if(!bpath) return -ENOENT;
if(!boxpath_getfile(bpath)) {
boxpath_free(bpath);
return -ENOENT;
}
stbuf->st_size = bpath->file->size;
stbuf->st_ctime = bpath->file->ctime;
stbuf->st_mtime = bpath->file->mtime;
// access time unknown, approx with mtime
stbuf->st_atime = bpath->file->mtime;
if(bpath->is_dir) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 2 + api_subdirs(path);
} else {
stbuf->st_mode = S_IFREG | 0444;
stbuf->st_nlink = 1;
}
boxpath_free(bpath);
return 0;
}
int api_removedir(const char * path)
{
int res = 0;
boxpath * bpath = boxpath_from_string(path);
if(!boxpath_getfile(bpath)) return -EINVAL;
char *buf, *status;
if(!bpath->dir && !bpath->is_dir) return -ENOENT;
buf = http_fetchf("%s" API_RMDIR "%s&target_id=%s", proto, auth_token, bpath->file->id);
status = node_value(buf,"status");
if(strcmp(status,API_UNLINK_OK)) {
res = -EPERM;
}
free(status);
free(buf);
if(!res) {
//remove it from parent's subdirs...
LOCKDIR(bpath->dir);
boxpath_removefile(bpath);
UNLOCKDIR(bpath->dir);
//...and from dir list
xmlHashRemoveEntry(allDirs, path, NULL);
}
boxpath_free(bpath);
return res;
}
/*
* Internal func to call the delete api on a file id.
* api_removefile will call it several times if
* splitfiles is on and the file has parts
*/
int do_removefile_id(const char * id)
{
int res = 0;
char *buf, *status;
buf = http_fetchf("%s" API_UNLINK "%s&target_id=%s", proto, auth_token, id);
status = node_value(buf,"status");
if(strcmp(status,API_UNLINK_OK)) res = -ENOENT;
free(status);
free(buf);
return res;
}
int api_removefile(const char * path)
{
int res = 0;
boxpath * bpath = boxpath_from_string(path);
if(!bpath->dir) res = -ENOENT;
else {
//remove it from box.net
boxpath_getfile(bpath);
do_removefile_id(bpath->file->id);
if(res==0) {
if(options.splitfiles && list_size(bpath->dir->pieces)) {
list_iter prev,cur;
boxfile * part;
//remove parts
for(cur = boxpath_first_part(bpath); cur; ) {
part = (boxfile*) list_iter_getval(cur);
if (options.verbose) syslog(LOG_DEBUG, "removing part %s", part->name);
do_removefile_id(part->id);
prev = cur; cur = boxpath_next_part(bpath, cur);
list_delete_item(bpath->dir->pieces, part);
}
}
//remove it from the list
LOCKDIR(bpath->dir);
boxpath_removefile(bpath);
UNLOCKDIR(bpath->dir);
}
}
boxpath_free(bpath);
return res;
}
//Move and rename funcs, new version
int do_api_move_id(int is_dir, const char * srcid, const char * dstid)
{
char * buf = NULL, * status;
int res = 0;
buf = http_fetchf("%s" API_MOVE "%s&target=%s&target_id=%s&destination_id=%s",
proto, auth_token, (is_dir ? "folder" : "file"), srcid, dstid);
status = node_value(buf,"status");
if(strcmp(status,API_MOVE_OK)) {
res = -EINVAL;
}
free(status); free(buf);
return res;
}
int do_api_move(boxpath * bsrc, boxpath * bdst)
{
int res = 0;
list_iter it;
LOCKDIR(bsrc->dir);
res = do_api_move_id(bsrc->is_dir, bsrc->file->id, bdst->dir->id);
if(!res) {
boxfile * part;
//take care of parts, if any
if(options.splitfiles && !bsrc->is_dir && list_size(bsrc->dir->pieces))
for(it = boxpath_first_part(bsrc); it; it = boxpath_next_part(bsrc, it)) {
part = (boxfile*)list_iter_getval(it);
if(options.verbose) syslog(LOG_DEBUG, "Moving part %s", part->name);
do_api_move_id(FALSE, part->id, bdst->dir->id);
list_insert_sorted_comp(bdst->dir->pieces, part, filename_compare);
list_delete_item(bsrc->dir->pieces, part);
}
boxpath_removefile(bsrc);
LOCKDIR(bdst->dir);
list_append((bsrc->is_dir ? bdst->dir->folders : bdst->dir->files),
bsrc->file);
UNLOCKDIR(bdst->dir);
}
UNLOCKDIR(bsrc->dir);
return res;
}
int do_api_rename_id(int is_dir, const char * id, const char * base)
{
char * buf = NULL, * status;
int res = 0;
buf = http_fetchf("%s" API_RENAME "%s&target=%s&target_id=%s&new_name=%s",
proto, auth_token, (is_dir ? "folder" : "file"),
id, xmlURIEscapeStr(base,""));
status = node_value(buf,"status");
if(strcmp(status,API_RENAME_OK)) {
res = -EINVAL;
}
free(status);free(buf);
return res;
}
int do_api_rename(boxpath * bsrc, boxpath * bdst)
{
int res;
LOCKDIR(bsrc->dir);
res = do_api_rename_id(bsrc->is_dir, bsrc->file->id, bdst->base);
if(!res) {
boxfile * part;
char * newname;
list_iter it, prev;
int ind=1;
//take care of parts, if any
if(options.splitfiles && !bsrc->is_dir && list_size(bsrc->dir->pieces))
for(it = boxpath_first_part(bsrc); it; ) {
part = (boxfile*)list_iter_getval(it);
newname = malloc(strlen(bdst->base)+ PART_SUFFIX_LEN +4);
sprintf(newname, "%s.%.2d" PART_SUFFIX, bdst->base, ind++);
if(options.verbose) syslog(LOG_DEBUG, "Renaming part %s to %s", part->name, newname);
do_api_rename_id(FALSE, part->id, newname);
prev = it; it = boxpath_next_part(bsrc, it);
list_delete_item(bsrc->dir->pieces, part);
part->name = newname;
list_insert_sorted_comp(bsrc->dir->pieces, part, filename_compare);
}
boxpath_renamefile(bsrc, bdst->base);
}
UNLOCKDIR(bsrc->dir);
return res;
}
int api_rename_v2(const char * from, const char * to)
{
int res = 0;
boxpath * bsrc = boxpath_from_string(from);
boxpath * bdst = boxpath_from_string(to);
if(!boxpath_getfile(bsrc)) return -EINVAL;
boxpath_getfile(bdst);
if(bsrc->dir!=bdst->dir) {
res=do_api_move(bsrc, bdst);
}
if(!res && strcmp(bsrc->base, bdst->base)) {
res = do_api_rename(bsrc,bdst);
}
if(!res && bsrc->is_dir) {
boxtree_movedir(from, to);
}
boxpath_free(bsrc);
boxpath_free(bdst);
return res;
}
void api_upload(const char * path, const char * tmpfile)
{
postdata_t buf = post_init();
char * res = NULL, * pr = NULL, * partname="";
char gkurl[512];
char * fid;
long fsize;
size_t start, len;
int oldver;
boxfile * aFile = NULL;
boxpath * bpath = boxpath_from_string(path);
if(bpath->dir) {
sprintf(gkurl, "%s" API_UPLOAD "%s/%s", proto, auth_token, bpath->dir->id);
fsize = filesize(tmpfile);
oldver = boxpath_getfile(bpath);
//if there was an older version of the file with parts, remove them
if(options.splitfiles && oldver && (bpath->file->size > PART_LEN)) {
api_removefile(path);
}
//upload file in parts if needed
if(options.splitfiles && fsize > PART_LEN) {
post_addfile_part(buf, bpath->base, tmpfile, 0, PART_LEN);
res = http_postfile(gkurl, buf);
fid = attr_value(res,"id");
if(fid) set_filedata(bpath ,fid, fsize);
free(res);
start = PART_LEN;
while(start < fsize-1) {
post_free(buf); buf = post_init();
partname = (char*) malloc(strlen(bpath->base)+PART_SUFFIX_LEN+4);
sprintf(partname, "%s.%.2d%s", bpath->base, (int)(start/PART_LEN), PART_SUFFIX);
if(options.verbose) syslog(LOG_DEBUG, "Uploading file part %s", partname);
len = MIN(PART_LEN, fsize-start);
pr = post_addfile_part(buf, partname, tmpfile, start, len);
res = http_postfile(gkurl, buf);
fid = attr_value(res,"id");
aFile = boxfile_create(partname);
aFile->id=fid;
LOCKDIR(bpath->dir);
list_append(bpath->dir->pieces, aFile);
UNLOCKDIR(bpath->dir);
free(pr); free(res); free(partname);
start = start + len;
}
} else if(fsize) {
//normal upload
post_addfile(buf, bpath->base, tmpfile);
res = http_postfile(gkurl, buf);
fid = attr_value(res,"id");
if(fid) set_filedata(bpath ,fid, fsize);
free(res);
}
} else {
syslog(LOG_ERR,"Couldn't upload file %s",bpath->base);
}
post_free(buf);
boxpath_free(bpath);
}
/*
* Login to box.net, get the auth_token
*/
int api_init(int* argc, char*** argv) {
int res = 0;
/* parse command line arguments */
if (parse_options (argc, argv, &options))
return 1;
xmlInitParser();
openlog("boxfs", LOG_PID, LOG_USER);
proto = options.secure ? PROTO_HTTPS : PROTO_HTTP;
res = get_ticket(&options);
if(res) BOX_ERR("Unable to initialize Box.net connection.\n");
else {
res = get_key();
if(res) BOX_ERR("Error while logging in to Box.net.\n");
else {
res = get_tree();
if(res) BOX_ERR("Error while fetching user file tree\n");
}
}
if(!res) {
boxtree_setup(treefile);
unlink(treefile);
syslog(LOG_INFO, "Filesystem mounted on %s", options.mountpoint);
if(options.verbose) syslog(LOG_DEBUG, "Auth token is: %s", auth_token);
}
return res;
}