driver.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * mbsync - mailbox synchronizer
  3. * Copyright (C) 2000-2002 Michael R. Elkins <me@mutt.org>
  4. * Copyright (C) 2002-2006,2010-2012 Oswald Buddenhagen <ossi@users.sf.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * As a special exception, mbsync may be linked with the OpenSSL library,
  20. * despite that library's more restrictive license.
  21. */
  22. #include "driver.h"
  23. #include <stdlib.h>
  24. #include <string.h>
  25. driver_t *drivers[N_DRIVERS] = { &maildir_driver, &imap_driver };
  26. int
  27. count_generic_messages( message_t *msgs )
  28. {
  29. int count = 0;
  30. for (; msgs; msgs = msgs->next)
  31. count++;
  32. return count;
  33. }
  34. void
  35. free_generic_messages( message_t *msgs )
  36. {
  37. message_t *tmsg;
  38. for (; msgs; msgs = tmsg) {
  39. tmsg = msgs->next;
  40. free( msgs->msgid );
  41. free( msgs );
  42. }
  43. }
  44. void
  45. parse_generic_store( store_conf_t *store, conffile_t *cfg )
  46. {
  47. if (!strcasecmp( "Trash", cfg->cmd )) {
  48. store->trash = nfstrdup( cfg->val );
  49. } else if (!strcasecmp( "TrashRemoteNew", cfg->cmd )) {
  50. store->trash_remote_new = parse_bool( cfg );
  51. } else if (!strcasecmp( "TrashNewOnly", cfg->cmd )) {
  52. store->trash_only_new = parse_bool( cfg );
  53. } else if (!strcasecmp( "MaxSize", cfg->cmd )) {
  54. store->max_size = parse_size( cfg );
  55. } else if (!strcasecmp( "MapInbox", cfg->cmd )) {
  56. store->map_inbox = nfstrdup( cfg->val );
  57. } else if (!strcasecmp( "Flatten", cfg->cmd )) {
  58. const char *p;
  59. for (p = cfg->val; *p; p++) {
  60. if (*p == '/') {
  61. error( "%s:%d: flattened hierarchy delimiter cannot contain the canonical delimiter '/'\n", cfg->file, cfg->line );
  62. cfg->err = 1;
  63. return;
  64. }
  65. }
  66. store->flat_delim = nfstrdup( cfg->val );
  67. } else {
  68. error( "%s:%d: unknown keyword '%s'\n", cfg->file, cfg->line, cfg->cmd );
  69. cfg->err = 1;
  70. }
  71. }