src/irc_log.c
changeset 75 ff6272398d2e
parent 70 a9a4c5e6aa30
child 80 1b989bc67760
equal deleted inserted replaced
74:11ec458d1cbf 75:ff6272398d2e
   160     
   160     
   161     return SUCCESS;
   161     return SUCCESS;
   162 }
   162 }
   163 
   163 
   164 /**
   164 /**
   165  * Parse the prefix into a nickmask and pass on to irc_log_event
       
   166  */
       
   167 static err_t irc_log_event_prefix (struct irc_log_ctx *ctx, struct irc_log_chan *chan_ctx, const char *prefix,
       
   168         const char *type, const char *target, const char *message)
       
   169 {
       
   170     char prefix_buf[IRC_PREFIX_MAX];
       
   171     struct irc_nm nm;
       
   172     err_t err;
       
   173 
       
   174     // parse nickmask
       
   175     if ((err = irc_nm_parse(&nm, prefix_buf, prefix)))
       
   176         return err;
       
   177 
       
   178     // log
       
   179     return irc_log_event(ctx, chan_ctx, &nm, type, target, message);
       
   180 }
       
   181 
       
   182 /**
       
   183  * Log a simple channel event of the form:
   165  * Log a simple channel event of the form:
   184  *
   166  *
   185  * :nm <type> <channel> [<msg>]
   167  * :nm <type> <channel> [<msg>]
   186  */
   168  */
   187 static void irc_log_on_chan_generic (const struct irc_line *line, void *arg)
   169 static void irc_log_on_chan_generic (const struct irc_line *line, void *arg)
   188 {
   170 {
   189     struct irc_log_chan *chan_ctx = arg;
   171     struct irc_log_chan *chan_ctx = arg;
   190     
   172     
   191     const char *msg = line->args[1];
   173     const char *msg = line->args[1];
   192 
   174 
   193     irc_log_event_prefix(chan_ctx->ctx, chan_ctx, line->prefix, line->command, NULL, msg);
   175     irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, NULL, msg);
   194 }
   176 }
   195 
   177 
   196 /**
   178 /**
   197  * Log a MODE event on a channel
   179  * Log a MODE event on a channel
   198  *
   180  *
   219         if (ptr > message + 512)
   201         if (ptr > message + 512)
   220             break;
   202             break;
   221     }
   203     }
   222     
   204     
   223     // log
   205     // log
   224     irc_log_event_prefix(chan_ctx->ctx, chan_ctx, line->prefix, line->command, NULL, message);
   206     irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, NULL, message);
   225 }
   207 }
   226 
   208 
   227 /**
   209 /**
   228  * Log a KICK event on a channel
   210  * Log a KICK event on a channel
   229  *
   211  *
   234     struct irc_log_chan *chan_ctx = arg;
   216     struct irc_log_chan *chan_ctx = arg;
   235     
   217     
   236     const char *target = line->args[1];    
   218     const char *target = line->args[1];    
   237     const char *msg = line->args[2];
   219     const char *msg = line->args[2];
   238 
   220 
   239     irc_log_event_prefix(chan_ctx->ctx, chan_ctx, line->prefix, line->command, target, msg);
   221     irc_log_event(chan_ctx->ctx, chan_ctx, line->source, line->command, target, msg);
   240 }
   222 }
   241 
   223 
   242 /**
   224 /**
   243  * Our low-level channel-specific message handlers for logged channels.
   225  * Our low-level channel-specific message handlers for logged channels.
   244  *
   226  *