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

Diff of /imapfilter/log.c

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

revision 1.26 by lefcha, Sat Jul 13 21:19:23 2002 UTC revision 1.26.2.3 by lefcha, Fri Mar 28 16:57:52 2003 UTC
# Line 64  void error(const char *errmsg,...) Line 64  void error(const char *errmsg,...)
64    
65      vfprintf(stderr, errmsg, args);      vfprintf(stderr, errmsg, args);
66    
67      if (logfp) {      if ((options & OPTION_ERRORS) && logfp) {
68          vfprintf(logfp, errmsg, args);          vfprintf(logfp, errmsg, args);
69      }      }
70      va_end(args);      va_end(args);
# Line 158  int close_logfile(void) Line 158  int close_logfile(void)
158  void log_info(int flag, void *ptr)  void log_info(int flag, void *ptr)
159  {  {
160      static struct {      static struct {
161          char *server;          char *account;
         char *username;  
162          char *mbox;          char *mbox;
163          char *filter;          char *filter;
164          unsigned int *action;          unsigned int *action;
165            char *destaccount;
166          char *destmbox;          char *destmbox;
167          char *hdrs;          char *hdrs;
168      } inf = {      } inf = {
# Line 173  void log_info(int flag, void *ptr) Line 173  void log_info(int flag, void *ptr)
173          return;          return;
174    
175      switch (flag) {      switch (flag) {
176      case LOG_WRITE:      case LOG_PREAMBLE:
177          fprintf(logfp, "%s %s %s %s %s %s%s\n", get_time(),          fprintf(logfp, "%s %s %s %s %s%s %s\n", get_time(),
178                  inf.server, inf.username, inf.mbox, inf.filter,                  inf.account, inf.mbox, inf.filter,
179                  (*inf.action == FILTER_ACTION_DELETE ? "delete" :                  (*inf.action == FILTER_ACTION_DELETE ? "delete" :
180                   *inf.action == FILTER_ACTION_COPY ? "copy " :                   *inf.action == FILTER_ACTION_COPY ? "copy" :
181                   *inf.action == FILTER_ACTION_MOVE ? "move " : "list"),                   *inf.action == FILTER_ACTION_MOVE ? "move" :
182                     *inf.action == FILTER_ACTION_RCOPY ? "rcopy " :
183                     *inf.action == FILTER_ACTION_RMOVE ? "rmove " :
184                     *inf.action == FILTER_ACTION_FLAG_ADD ||
185                     *inf.action == FILTER_ACTION_FLAG_REMOVE ||
186                     *inf.action == FILTER_ACTION_FLAG_REPLACE ? "flag" :
187                     *inf.action == FILTER_ACTION_LIST ? "list" :
188                     "unknown"),
189                    (inf.destaccount == NULL ? "" : inf.destaccount),
190                  (!*inf.destmbox ? "" : inf.destmbox));                  (!*inf.destmbox ? "" : inf.destmbox));
191            fflush(logfp);
         if (ptr) {  
             inf.hdrs = (char *)ptr;  
             fprintf(logfp, "%c", '\t');  
             while (*inf.hdrs) {  
                 if (*inf.hdrs == '\n') {  
                     fprintf(logfp, "%c", '\n');  
                     if (*(inf.hdrs + 1))  
                         fprintf(logfp, "%c", '\t');  
                     inf.hdrs++;  
                 } else  
                     fprintf(logfp, "%c", *(inf.hdrs++));  
             }  
         }  
192          break;          break;
193      case LOG_SERVER:      case LOG_ACCOUNT:
194          inf.server = (char *)ptr;          inf.account = (char *)ptr;
         break;  
     case LOG_USERNAME:  
         inf.username = (char *)ptr;  
195          break;          break;
196      case LOG_MAILBOX:      case LOG_MAILBOX:
197          inf.mbox = (char *)ptr;          inf.mbox = (char *)ptr;
# Line 210  void log_info(int flag, void *ptr) Line 202  void log_info(int flag, void *ptr)
202      case LOG_ACTION:      case LOG_ACTION:
203          inf.action = (unsigned int *)ptr;          inf.action = (unsigned int *)ptr;
204          break;          break;
205        case LOG_DESTINATION_ACCOUNT:
206            if (ptr == NULL)
207                inf.destaccount = NULL;
208            else
209                inf.destaccount = ((account_t *) ptr)->key;
210            break;
211      case LOG_DESTINATION_MAILBOX:      case LOG_DESTINATION_MAILBOX:
212          inf.destmbox = (char *)ptr;          inf.destmbox = (char *)ptr;
213          break;          break;
214        case LOG_HEADER:
215                if (ptr) {
216                    inf.hdrs = (char *)ptr;
217                    fprintf(logfp, "%c", '\t');
218                    while (*inf.hdrs) {
219                        if (*inf.hdrs == '\r') {
220                            fprintf(logfp, "%c", '\n');
221                            if (*(inf.hdrs + 2))
222                                fprintf(logfp, "%c", '\t');
223                            inf.hdrs += 2;
224                        } else
225                            fprintf(logfp, "%c", *(inf.hdrs++));
226                    }
227                }
228            fflush(logfp);
229            break;
230      }      }
231  }  }
232    
233    
234    
235  /*  /*
236   * Return current local time and date.   * Return current local time and date.
237   */   */

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.26.2.3

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26