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

Diff of /imapfilter/log.c

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

revision 1.12 by lefcha, Sun Sep 30 20:21:57 2001 UTC revision 1.13 by lefcha, Mon Oct 1 11:48:51 2001 UTC
# Line 27  void info(const char *info, ...) Line 27  void info(const char *info, ...)
27  {  {
28      va_list args;      va_list args;
29            
30      va_start(args, info);      if (options & OPTION_DETAILS_QUITE)
   
     if (!(options & OPTION_DETAILS_QUITE))  
         vprintf(info, args);  
   
     va_end(args);  
 }  
   
   
 /*  
  *  
  */  
 void log_info(int flag, void *ptr)  
 {  
     static struct {  
         char *server;  
         char *mbox;  
         unsigned int *action;  
         char *destmbox;  
         char *hdrs;  
     } inf = {  
         NULL, NULL, NULL, NULL, NULL  
     };  
       
     if (!logfp)  
31          return;          return;
32            
33      switch(flag) {      va_start(args, info);
34      case 0:      vprintf(info, args);
35          fprintf(logfp, "%s %s %s %s%s\n", get_time(), inf.server, inf.mbox,      va_end(args);
             (*inf.action == FILTER_ACTION_DELETE ? "delete" :  
              *inf.action == FILTER_ACTION_COPY ? "copy " :  
              *inf.action == FILTER_ACTION_MOVE ? "move " : "list"),  
             (!inf.destmbox ? "" : inf.destmbox));  
           
         if (ptr) {  
             inf.hdrs = (char *) ptr;  
             fputc('\t', logfp);  
             while (*inf.hdrs) {  
                 if (*inf.hdrs == '\n') {  
                     fputc('\n', logfp);  
                     if (*(inf.hdrs + 1))  
                         fputc('\t', logfp);  
                     inf.hdrs++;  
                 } else  
                     fputc(*(inf.hdrs++), logfp);  
             }  
         }  
         break;  
     case 1:  
         inf.server = (char *) ptr;  
         break;  
     case 2:  
         inf.mbox = (char *) ptr;  
         break;  
     case 3:  
         inf.action = (unsigned int *) ptr;  
         break;  
     case 4:  
         inf.destmbox = (char *) ptr;  
         break;  
     default:  
         break;  
     }  
36  }  }
           
           
37    
38    
39  /*  /*
# Line 212  int close_logfile(void) Line 152  int close_logfile(void)
152    
153    
154  /*  /*
155     * Prepares the log entry to be saved through continues calls, and writes it
156     * to logfile.
157     */
158    void log_info(int flag, void *ptr)
159    {
160        static struct {
161            char *server;
162            char *username;
163            char *mbox;
164            char *filter;
165            unsigned int *action;
166            char *destmbox;
167            char *hdrs;
168        } inf = {
169            NULL, NULL, NULL, NULL, NULL, NULL, NULL
170        };
171        
172        if (!logfp)
173            return;
174        
175        switch(flag) {
176        case LOG_WRITE:
177            fprintf(logfp, "%s %s %s %s %s %s%s\n", get_time(),
178                    inf.server, inf.username, inf.mbox, inf.filter,
179                    (*inf.action == FILTER_ACTION_DELETE ? "delete" :
180                     *inf.action == FILTER_ACTION_COPY ? "copy " :
181                     *inf.action == FILTER_ACTION_MOVE ? "move " : "list"),
182                    (!inf.destmbox ? "" : inf.destmbox));
183            
184            if (ptr) {
185                inf.hdrs = (char *) ptr;
186                fputc('\t', logfp);
187                while (*inf.hdrs) {
188                    if (*inf.hdrs == '\n') {
189                        fputc('\n', logfp);
190                        if (*(inf.hdrs + 1))
191                            fputc('\t', logfp);
192                        inf.hdrs++;
193                    } else
194                        fputc(*(inf.hdrs++), logfp);
195                }
196            }
197            break;
198        case LOG_SERVER:
199            inf.server = (char *) ptr;
200            break;
201        case LOG_USERNAME:
202            inf.username = (char *) ptr;
203        case LOG_MAILBOX:
204            inf.mbox = (char *) ptr;
205            break;
206        case LOG_FILTER:
207            inf.filter = (char *) ptr;
208        case LOG_ACTION:
209            inf.action = (unsigned int *) ptr;
210            break;
211        case LOG_DESTINATION_MAILBOX:
212            inf.destmbox = (char *) ptr;
213            break;
214        default:
215            break;
216        }
217    }
218            
219    
220    /*
221   * Return current local time and date.   * Return current local time and date.
222   */   */
223  char *get_time(void)  char *get_time(void)

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26