5607 } |
5607 } |
5608 } |
5608 } |
5609 |
5609 |
5610 |
5610 |
5611 int cmd_add_directory(CmdArgs *args) { |
5611 int cmd_add_directory(CmdArgs *args) { |
5612 /* |
5612 DavConfig *davconfig = get_config(); |
5613 if(!get_repositories()) { |
5613 |
|
5614 if(!davconfig->repositories) { |
5614 fprintf(stderr, "No repositories available. Run 'dav add-repository' first.\n"); |
5615 fprintf(stderr, "No repositories available. Run 'dav add-repository' first.\n"); |
5615 fprintf(stderr, "Abort\n"); |
5616 fprintf(stderr, "Abort\n"); |
5616 return -1; |
5617 return -1; |
5617 } |
5618 } |
5618 */ |
5619 |
5619 |
|
5620 // TODO: port to ucx 3 |
|
5621 return 1; |
|
5622 #if 0 |
|
5623 |
|
5624 log_printf("Each sync directory must have an unique name.\n"); |
5620 log_printf("Each sync directory must have an unique name.\n"); |
5625 char *name = assistant_getcfg("name"); |
5621 char *name = assistant_getcfg("name"); |
5626 if(!name) { |
5622 if(!name) { |
5627 fprintf(stderr, "Abort\n"); |
5623 fprintf(stderr, "Abort\n"); |
5628 return -1; |
5624 return -1; |
5638 fprintf(stderr, "Abort\n"); |
5634 fprintf(stderr, "Abort\n"); |
5639 return -1; |
5635 return -1; |
5640 } |
5636 } |
5641 |
5637 |
5642 log_printf("Specify webdav repository.\n"); |
5638 log_printf("Specify webdav repository.\n"); |
5643 CxIterator repos = get_repositories(); |
|
5644 int i = 0; |
5639 int i = 0; |
5645 cx_foreach(Repository *, r, repos) { |
5640 for (DavCfgRepository *r = davconfig->repositories; r != NULL; r = r->next) { |
5646 log_printf("%d) %s\n", i, r->name); |
5641 log_printf("%d) %s\n", i, r->name.value.ptr); |
5647 i++; |
5642 i++; |
5648 } |
5643 } |
5649 char *repository = assistant_getcfg("repository"); |
5644 char *repository = assistant_getcfg("repository"); |
5650 char *reponame = NULL; |
5645 char *reponame = NULL; |
5651 if(!repository) { |
5646 if(!repository) { |
5656 if(util_strtoint(repository, &reponum)) { |
5651 if(util_strtoint(repository, &reponum)) { |
5657 if(reponum < 0) { |
5652 if(reponum < 0) { |
5658 fprintf(stderr, "Wrong input.\nAbort\n"); |
5653 fprintf(stderr, "Wrong input.\nAbort\n"); |
5659 return -1; |
5654 return -1; |
5660 } |
5655 } |
5661 UcxList *elm = ucx_list_get(repos, reponum); |
5656 DavCfgRepository *r = cx_linked_list_at(davconfig->repositories, 0, |
5662 if(elm) { |
5657 offsetof(DavCfgRepository, next), |
5663 Repository *r = elm->data; |
5658 reponum); |
5664 reponame = r->name; |
5659 if(r != NULL) { |
|
5660 reponame = r->name.value.ptr; |
5665 } else { |
5661 } else { |
5666 fprintf(stderr, "Wrong input.\nAbort\n"); |
5662 fprintf(stderr, "Wrong input.\nAbort\n"); |
5667 return -1; |
5663 return -1; |
5668 } |
5664 } |
5669 } else { |
5665 } else { |
5670 if(get_repository(sstr(repository))) { |
5666 if(dav_config_get_repository(davconfig, cx_str(repository))) { |
5671 reponame = repository; |
5667 reponame = repository; |
5672 } else { |
5668 } else { |
5673 fprintf(stderr, "Repository %s doesn't exist.\nAbort\n", repository); |
5669 fprintf(stderr, "Repository %s doesn't exist.\nAbort\n", repository); |
5674 return -1; |
5670 return -1; |
5675 } |
5671 } |