/[imapfilter]/imapfilter/account.c
ViewVC logotype

Diff of /imapfilter/account.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by lefcha, Thu Jul 31 15:46:02 2003 UTC revision 1.6 by lefcha, Mon Feb 9 17:34:56 2004 UTC
# Line 1  Line 1 
1  #include <stdio.h>  #include <stdio.h>
2    #include <stdlib.h>
3  #include <string.h>  #include <string.h>
4  #include <ctype.h>  #include <ctype.h>
5  #include <limits.h>  #include <limits.h>
6    #include <sys/types.h>          /* IEEE Std 1003.1-2001 non-conformance. */
7    #include <regex.h>
8    
9  #include "config.h"  #include "config.h"
10  #include "imapfilter.h"  #include "imapfilter.h"
# Line 14  extern unsigned int flags; Line 17  extern unsigned int flags;
17  account_t *accounts = NULL;     /* First node of accounts linked list. */  account_t *accounts = NULL;     /* First node of accounts linked list. */
18  mboxgrp_t *mboxgrps = NULL;     /* First node of mailbox-groups tree. */  mboxgrp_t *mboxgrps = NULL;     /* First node of mailbox-groups tree. */
19    
20  static account_t *cur_acct = NULL;      /* Current account. */  account_t *cur_acct = NULL;     /* Current account. */
21    
22    
23  void init_account(account_t * node);  void init_account(account_t * node);
# Line 63  set_account(char *line, regmatch_t * m) Line 66  set_account(char *line, regmatch_t * m)
66          strncat(node->key, line + m[1].rm_so,          strncat(node->key, line + m[1].rm_so,
67              min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1));              min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1));
68    
69  #ifdef DEBUG          debug("ACCOUNT: '%s'\n", node->key);
         fprintf(stderr, "debug: ACCOUNT: '%s'\n", node->key);  
 #endif  
70    
71          if (m[3].rm_so != -1) {          if (m[3].rm_so != -1) {
72                  strncat(node->username, line + m[3].rm_so,                  strncat(node->username, line + m[3].rm_so,
# Line 78  set_account(char *line, regmatch_t * m) Line 79  set_account(char *line, regmatch_t * m)
79                  if (string_decode(node->username))                  if (string_decode(node->username))
80                          return ERROR_CONFIG_PARSE;                          return ERROR_CONFIG_PARSE;
81    
82  #ifdef DEBUG          debug("USERNAME: '%s'\n", node->username);
         fprintf(stderr, "debug: USERNAME: '%s'\n", node->username);  
 #endif  
83    
84          if (m[4].rm_so != -1) {          if (m[4].rm_so != -1) {
85                  strncat(node->password, line + m[4].rm_so,                  strncat(node->password, line + m[4].rm_so,
# Line 92  set_account(char *line, regmatch_t * m) Line 91  set_account(char *line, regmatch_t * m)
91          } else          } else
92                  flags |= FLAG_BLANK_PASSWORD;                  flags |= FLAG_BLANK_PASSWORD;
93    
94  #ifdef DEBUG          debug("PASSWORD: '%s'\n", node->password);
         fprintf(stderr, "debug: PASSWORD: '%s'\n", node->password);  
 #endif  
95    
96          strncat(node->server, line + m[6].rm_so,          strncat(node->server, line + m[6].rm_so,
97              min(m[6].rm_eo - m[6].rm_so, SERVER_LEN - 1));              min(m[6].rm_eo - m[6].rm_so, SERVER_LEN - 1));
98    
99  #ifdef DEBUG          debug("SERVER: '%s'\n", node->server);
         fprintf(stderr, "debug: SERVER: '%s'\n", node->server);  
 #endif  
100    
101          if (m[7].rm_so != -1) {          if (m[7].rm_so != -1) {
102                  n = min(m[7].rm_eo - m[7].rm_so - 1, 5);                  n = min(m[7].rm_eo - m[7].rm_so - 1, 5);
103                  xstrncpy(p, line + m[7].rm_so + 1, n);                  xstrncpy(p, line + m[7].rm_so + 1, n);
104                  p[n] = '\0';                  p[n] = '\0';
105                  node->port = strtoul(p, NULL, 10);                  node->port = strtoul(p, NULL, 10);
106  #ifdef DEBUG                  debug("PORT: %d\n", node->port);
                 fprintf(stderr, "debug: PORT: %d\n", node->port);  
 #endif  
107          }          }
108          if (m[8].rm_so != -1) {          if (m[8].rm_so != -1) {
109                  if (m[7].rm_so == -1)                  if (m[7].rm_so == -1)
# Line 184  set_mboxgrp(char *line, regmatch_t * m) Line 177  set_mboxgrp(char *line, regmatch_t * m)
177          strncat(node->key, line + m[1].rm_so,          strncat(node->key, line + m[1].rm_so,
178              min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1));              min(m[1].rm_eo - m[1].rm_so, KEY_LEN - 1));
179    
180  #ifdef DEBUG          debug("FOLDER: '%s'\n", node->key);
         fprintf(stderr, "debug: FOLDER: '%s'\n", node->key);  
 #endif  
181    
182          strncat(mboxs, line + m[2].rm_so,          strncat(mboxs, line + m[2].rm_so,
183              min(m[2].rm_eo - m[2].rm_so, LINE_MAX - 1));              min(m[2].rm_eo - m[2].rm_so, LINE_MAX - 1));
# Line 259  set_mbox(char *name) Line 250  set_mbox(char *name)
250    
251          strncat(node->name, s, MBOX_NAME_LEN - 1);          strncat(node->name, s, MBOX_NAME_LEN - 1);
252    
253  #ifdef DEBUG          debug("MBOX: '%s'\n", node->name);
         fprintf(stderr, "debug: MBOX: '%s'\n", node->name);  
 #endif  
254    
255          APPEND_LINKED_LIST(cur_acct->mboxes, node, mbox);          APPEND_LINKED_LIST(cur_acct->mboxes, node, mbox);
256    
# Line 329  apply_namespace(char *mbox, char *prefix Line 318  apply_namespace(char *mbox, char *prefix
318          while ((c = strchr(c, '/')))          while ((c = strchr(c, '/')))
319                  *(c++) = delim;                  *(c++) = delim;
320    
321  #ifdef DEBUG          debug("MAILBOX: '%s'\n", m);
         fprintf(stderr, "debug: MAILBOX: '%s'\n", m);  
 #endif  
322    
323          return m;          return m;
324  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26