src/irc_net.c
changeset 63 d399a1d915a3
parent 53 12d806823775
child 68 591a574f390e
equal deleted inserted replaced
62:e0dabc496f64 63:d399a1d915a3
   218 
   218 
   219     // ourselves
   219     // ourselves
   220     free(net);
   220     free(net);
   221 }
   221 }
   222 
   222 
   223 struct irc_chan* irc_net_add_chan (struct irc_net *net, const struct irc_chan_info *info)
   223 err_t irc_net_add_chan (struct irc_net *net, struct irc_chan **chan_ptr, const struct irc_chan_info *info, struct error_info *err)
   224 {
   224 {
   225     struct irc_chan *chan;
   225     struct irc_chan *chan;
   226     struct error_info err;
       
   227 
   226 
   228     // create the new irc_chan struct
   227     // create the new irc_chan struct
   229     if (irc_chan_create(&chan, net, info, &err))
   228     if (irc_chan_create(&chan, net, info, err))
   230         // XXX: we lose error info
   229         return ERROR_CODE(err);
   231         return NULL;
       
   232     
   230     
   233     // add to network list
   231     // add to network list
   234     TAILQ_INSERT_TAIL(&net->channels, chan, node);
   232     TAILQ_INSERT_TAIL(&net->channels, chan, node);
   235     
   233     
   236     // currently connected?
   234     // currently connected?
   237     if (net->conn && net->conn->registered) {
   235     if (net->conn && net->conn->registered) {
   238         // then join
   236         // then join
   239         if ((ERROR_CODE(&err) = irc_chan_join(chan)))
   237         if ((ERROR_CODE(err) = irc_chan_join(chan)))
   240             // XXX
   238             return ERROR_CODE(err);
   241             return NULL;
   239     }
   242     }
   240 
   243 
   241     // ok
   244     // ok, return
   242     if (chan_ptr)
   245     return chan;
   243         *chan_ptr = chan;
       
   244 
       
   245     return SUCCESS;
   246 }
   246 }
   247 
   247 
   248 struct irc_chan* irc_net_get_chan (struct irc_net *net, const char *channel)
   248 struct irc_chan* irc_net_get_chan (struct irc_net *net, const char *channel)
   249 {
   249 {
   250     struct irc_chan *chan = NULL;
   250     struct irc_chan *chan = NULL;