driver.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. void
  27. free_generic_messages( message_t *msgs )
  28. {
  29. message_t *tmsg;
  30. for (; msgs; msgs = tmsg) {
  31. tmsg = msgs->next;
  32. free( msgs->msgid );
  33. free( msgs );
  34. }
  35. }
  36. void
  37. parse_generic_store( store_conf_t *store, conffile_t *cfg )
  38. {
  39. if (!strcasecmp( "Trash", cfg->cmd )) {
  40. store->trash = nfstrdup( cfg->val );
  41. } else if (!strcasecmp( "TrashRemoteNew", cfg->cmd )) {
  42. store->trash_remote_new = parse_bool( cfg );
  43. } else if (!strcasecmp( "TrashNewOnly", cfg->cmd )) {
  44. store->trash_only_new = parse_bool( cfg );
  45. } else if (!strcasecmp( "MaxSize", cfg->cmd )) {
  46. store->max_size = parse_size( cfg );
  47. } else if (!strcasecmp( "MapInbox", cfg->cmd )) {
  48. store->map_inbox = nfstrdup( cfg->val );
  49. } else if (!strcasecmp( "Flatten", cfg->cmd )) {
  50. const char *p;
  51. for (p = cfg->val; *p; p++) {
  52. if (*p == '/') {
  53. error( "%s:%d: flattened hierarchy delimiter cannot contain the canonical delimiter '/'\n", cfg->file, cfg->line );
  54. cfg->err = 1;
  55. return;
  56. }
  57. }
  58. store->flat_delim = nfstrdup( cfg->val );
  59. } else {
  60. error( "%s:%d: unknown keyword '%s'\n", cfg->file, cfg->line, cfg->cmd );
  61. cfg->err = 1;
  62. }
  63. }