2 * Copyright (C) 1998 Peter Zelezny.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 #include <sys/types.h>
33 #include "util.h" /* token_foreach */
45 int loginmode
; /* default authentication type */
48 static const struct defaultserver def
[] =
54 {0, "irc.7-indonesia.org"},
57 {0, "irc.accessirc.net"},
58 {0, "eu.accessirc.net"},
61 {0, "irc.afternet.org"},
62 {0, "us.afternet.org"},
63 {0, "eu.afternet.org"},
68 {0, "irc6.ktu.lt/+7668"},
70 {0, "irc6.ktu.lt/7666"},
73 {0, "irc.data.lt/+6668"},
74 {0, "irc-ssl.omnitel.net/+6668"},
75 {0, "irc-ssl.le.lt/+9999"},
78 {0, "irc.omnitel.net"},
86 {0, "irc.amiganet.org"},
87 {0, "us.amiganet.org"},
88 {0, "uk.amiganet.org"},
89 /* {0, "no.amiganet.org"},
90 {0, "au.amiganet.org"},*/
93 {0, "se1.arcnet.vapor.com"},
94 {0, "us1.arcnet.vapor.com"},
95 {0, "us2.arcnet.vapor.com"},
96 {0, "us3.arcnet.vapor.com"},
97 {0, "ca1.arcnet.vapor.com"},
98 {0, "de1.arcnet.vapor.com"},
99 {0, "de3.arcnet.vapor.com"},
100 {0, "ch1.arcnet.vapor.com"},
101 {0, "be1.arcnet.vapor.com"},
102 {0, "nl3.arcnet.vapor.com"},
103 {0, "uk1.arcnet.vapor.com"},
104 {0, "uk2.arcnet.vapor.com"},
105 /* {0, "uk3.arcnet.vapor.com"},*/
106 {0, "fr1.arcnet.vapor.com"},
109 {0, "irc.astrolink.org"},
112 {0, "au.austnet.org"},
113 {0, "us.austnet.org"},
114 {0, "ca.austnet.org"},
117 {0, "irc.axenet.org"},
118 {0, "angel.axenet.org"},
119 {0, "energy.axenet.org"},
120 {0, "python.axenet.org"},*/
123 {0, "irc.azzurra.org"},
124 {0, "crypto.azzurra.org"},
127 {0, "irc.beirut.com"},
130 {0, "irc.chattingaway.com"},
132 {"ChatJunkies", 0, "#xchat"},
133 {0, "irc.chatjunkies.org"},
134 {0, "nl.chatjunkies.org"},
137 {0, "US.ChatNet.Org"},
138 {0, "EU.ChatNet.Org"},
141 {0, "us.chatsociety.net"},
142 {0, "eu.chatsociety.net"},
145 {0, "irc.chatspike.net"},
148 {0, "irc.coolchat.net"},
149 /* {0, "unix.coolchat.net"},
150 {0, "toronto.coolchat.net"},*/
153 {0, "irc.criten.net"},
154 {0, "irc.eu.criten.net"},
158 {0, "irc.eu.dal.net"},
161 {0, "irc.d-t-net.de"},
162 {0, "bw.d-t-net.de"},
163 {0, "nc.d-t-net.de"},
164 {0, "wakka.d-t-net.de"},
167 {0, "irc.darkmyst.org"},
170 {0, "irc.deepirc.net"},
173 {0, "irc.deltaanime.net"},
176 {0, "irc.blackened.com"},
177 {0, "irc.Prison.NET"},
178 {0, "irc.Qeast.net"},
180 {0, "efnet.demon.co.uk"},
181 /* {0, "irc.lagged.org"},*/
182 {0, "irc.lightning.net"},
183 {0, "irc.mindspring.com"},
184 {0, "irc.easynews.com"},
185 {0, "irc.servercentral.net"},
188 {0, "IRC.EnterTheGame.Com"},
191 {0, "irc.esper.net/+6697"},
192 {0, "na.irc.esper.net/+6697"},
193 {0, "eu.irc.esper.net/+6697"},
196 {0, "irc.euirc.net"},
197 {0, "irc.ham.de.euirc.net"},
198 {0, "irc.ber.de.euirc.net"},
199 {0, "irc.ffm.de.euirc.net"},
200 {0, "irc.bre.de.euirc.net"},
201 {0, "irc.hes.de.euirc.net"},
202 {0, "irc.vie.at.euirc.net"},
203 {0, "irc.inn.at.euirc.net"},
204 {0, "irc.bas.ch.euirc.net"},
207 {0, "irc.europnet.org"},
210 {0, "irc.eu-irc.net"},
213 {0, "irc.fdfnet.net"},
214 {0, "irc.eu.fdfnet.net"},
219 {0, "irc.vendetta.com"},
221 {"freenode", 0, "#xchat", 0, LOGIN_SASL
},
222 {0, "chat.freenode.net/+6697"},
225 {0, "kabel.freeworld.nu"},
226 {0, "irc.freeworld.nu"},*/
229 {0, "irc.galaxynet.org"},
230 /* {0, "sprynet.us.galaxynet.org"},
231 {0, "atlanta.ga.us.galaxynet.org"},*/
234 {0, "irc.gamesnet.net"},
235 /* {0, "irc.us.gamesnet.net"},
236 {0, "east.us.gamesnet.net"},
237 {0, "west.us.gamesnet.net"},*/
238 {0, "irc.ca.gamesnet.net"},
239 {0, "irc.eu.gamesnet.net"},
242 {0, "irc.geekshed.net"},
245 {0, "dominion.german-elite.net"},
246 {0, "komatu.german-elite.net"},
247 /* {0, "liberty.german-elite.net"},*/
251 /* {0, "irc.au.gimp.org"},*/
252 {0, "irc.us.gimp.org"},
255 {0, "irc.habber.net"},
258 {0, "irc.hashmark.net"},
261 {0, "irc.idlemonkeys.net"},
263 /* {"Infinity-IRC", 0},
264 {0, "Atlanta.GA.US.Infinity-IRC.Org"},
265 {0, "Babylon.NY.US.Infinity-IRC.Org"},
266 {0, "Sunshine.Ca.US.Infinity-IRC.Org"},
267 {0, "IRC.Infinity-IRC.Org"},*/
270 {0, "irc.iZ-smart.net/6666"},
271 {0, "irc.iZ-smart.net/6667"},
272 {0, "irc.iZ-smart.net/6668"},
275 {0, "irc.irclink.net"},
276 {0, "Alesund.no.eu.irclink.net"},
277 {0, "Oslo.no.eu.irclink.net"},
278 {0, "frogn.no.eu.irclink.net"},
279 {0, "tonsberg.no.eu.irclink.net"},
282 {0, "irc.ircnet.com"},
283 {0, "irc.stealth.net/6668"},
284 {0, "ircnet.demon.co.uk"},
285 /* {0, "ircnet.hinet.hr"},*/
286 {0, "irc.datacomm.ch"},
287 /* {0, "ircnet.kaptech.fr"},
288 {0, "ircnet.easynet.co.uk"},*/
289 {0, "random.ircd.de"},
290 {0, "ircnet.netvision.net.il"},
291 /* {0, "irc.seed.net.tw"},*/
292 {0, "irc.cs.hut.fi"},
295 {0, "irc.irctoo.net"},
298 {0, "irc.krstarica.com"},
301 {0, "irc.librenet.net"},
302 {0, "ielf.fr.librenet.net"},
305 {0, "irc.link-net.org"},
306 {0, "irc.no.link-net.org"},
307 /* {0, "irc.gamesden.net.au"},*/
308 {0, "irc.bahnhof.se"},
309 /* {0, "irc.kinexuseurope.co.uk"},
310 {0, "irc.gamiix.com"},*/
313 {0, "irc.magicstar.net"},
316 {0, "irc.majistic.net"},
319 {0, "irc.mindforge.org"},
322 {0, "irc.mintirc.net"},
325 {0, "irc.mixxnet.net"},
328 {0, "irc.nevernet.net"},
329 {0, "imagine.nevernet.net"},
330 {0, "dimension.nevernet.net"},
331 {0, "universe.nevernet.net"},
332 {0, "wayland.nevernet.net"},
333 {0, "forte.nevernet.net"},
336 {0, "irc.nixhelp.org"},
337 {0, "us.nixhelp.org"},
338 {0, "uk.nixhelp.org"},
339 {0, "uk2.nixhelp.org"},
340 {0, "uk3.nixhelp.org"},
341 {0, "nl.nixhelp.org"},
342 {0, "ca.ld.nixhelp.org"},
343 {0, "us.co.nixhelp.org"},
344 {0, "us.ca.nixhelp.org"},
345 {0, "us.pa.nixhelp.org"},
348 {0, "irc.nullus.net"},
351 {0, "irc.oceanius.com"},
354 {0, "irc.oftc.net/+6697"},
357 {0, "irc.othernet.org"},
366 {0, "irc.PTlink.net"},
367 {0, "aaia.PTlink.net"},
370 {0, "irc.PTNet.org"},
371 {0, "world.PTnet.org"},
372 {0, "netvisao.PTnet.org"},
373 {0, "uevora.PTnet.org"},
374 {0, "vianetworks.PTnet.org"},
376 {0, "nfsi.ptnet.org"},
378 {"QuakeNet", 0, 0, 0, LOGIN_CHALLENGEAUTH
},
379 {0, "irc.quakenet.org"},
380 {0, "irc.se.quakenet.org"},
381 {0, "irc.dk.quakenet.org"},
382 {0, "irc.no.quakenet.org"},
383 {0, "irc.fi.quakenet.org"},
384 {0, "irc.be.quakenet.org"},
385 {0, "irc.uk.quakenet.org"},
386 {0, "irc.de.quakenet.org"},
387 {0, "irc.it.quakenet.org"},
390 {0, "irc.rebelchat.org"},
392 /* {"Recycled-IRC", 0},
393 {0, "irc.recycled-irc.org"},
394 {0, "vermin.recycled-irc.org"},
395 {0, "waste.recycled-irc.org"},
396 {0, "lumber.recycled-irc.org"},
397 {0, "trash.recycled-irc.org"},
398 {0, "unwashed.recycled-irc.org"},
399 {0, "garbage.recycled-irc.org"},
400 {0, "dustbin.recycled-irc.org"},*/
403 {0, "irc.rizenet.org"},
404 {0, "omega.rizenet.org"},
405 {0, "evelance.rizenet.org"},
406 {0, "lisa.rizenet.org"},
407 {0, "scott.rizenet.org"},
410 {0, "irc.rizon.net/+6697"},
412 {"RusNet", 0, 0, "KOI8-R (Cyrillic)"},
413 {0, "irc.tomsk.net"},
417 {0, "irc.lucky.net"},
420 {0, "irc.scene.org"},
421 {0, "irc.eu.scene.org"},
422 {0, "irc.us.scene.org"},
425 {0, "irc.seilen.de"},
428 {0, "irc.slashnet.org"},
429 {0, "area51.slashnet.org"},
430 {0, "moo.slashnet.org"},
431 {0, "radon.slashnet.org"},
434 {0, "irc.sohbet.net"},
437 {0, "irc.solidirc.com"},
440 {0, "irc.sorcery.net/9000"},
441 {0, "irc.us.sorcery.net/9000"},
442 {0, "irc.eu.sorcery.net/9000"},
445 {0, "us.spidernet.org"},
446 {0, "eu.spidernet.org"},
447 {0, "irc.spidernet.org"},
450 {0, "irc.starchat.net"},
451 {0, "gainesville.starchat.net"},
452 {0, "freebsd.starchat.net"},
453 {0, "sunset.starchat.net"},
454 {0, "revenge.starchat.net"},
455 {0, "tahoma.starchat.net"},
456 {0, "neo.starchat.net"},
462 {0, "irc.turli.net"},
464 {0, "irc.gavnos.ru"},
466 {"UnderNet", 0, 0, 0, LOGIN_CUSTOM
},
467 {0, "us.undernet.org"},
468 {0, "eu.undernet.org"},
470 {"UniBG", 0, 0, 0, LOGIN_CUSTOM
},
471 {0, "irc.lirex.com"},
472 {0, "irc.naturella.com"},
473 {0, "irc.spnet.net"},
474 {0, "irc.techno-link.com"},
475 {0, "irc.telecoms.bg"},
476 {0, "irc.tu-varna.edu"},
479 {0, "irc.whiffle.org"},
482 {0, "irc.worldnet.net"},
483 {0, "irc.fr.worldnet.net"},
486 {0, "irc.xentonix.net"},
489 {0, "Buffalo.NY.US.XWorld.org"},
490 {0, "Minneapolis.MN.US.Xworld.Org"},
491 {0, "Rochester.NY.US.XWorld.org"},
492 {0, "Bayern.DE.EU.XWorld.Org"},
493 {0, "Chicago.IL.US.XWorld.Org"},
498 GSList
*network_list
= 0;
502 servlist_connect (session
*sess
, ircnet
*net
, gboolean join
)
510 sess
= new_ircwindow (NULL
, NULL
, SESS_SERVER
, TRUE
);
514 /* connect to the currently selected Server-row */
515 list
= g_slist_nth (net
->servlist
, net
->selected
);
517 list
= net
->servlist
;
520 ircserv
= list
->data
;
522 /* incase a protocol switch is added to the servlist gui */
523 server_fill_her_up (sess
->server
);
527 sess
->willjoinchannel
[0] = 0;
532 free (serv
->autojoin
);
533 serv
->autojoin
= strdup (net
->autojoin
);
539 serv
->loginmethod
= net
->logintype
;
543 serv
->loginmethod
= LOGIN_DEFAULT_REAL
;
546 serv
->password
[0] = 0;
549 safe_strcpy (serv
->password
, net
->pass
, sizeof (serv
->password
));
551 if (net
->flags
& FLAG_USE_GLOBAL
)
553 strcpy (serv
->nick
, prefs
.nick1
);
557 strcpy (serv
->nick
, net
->nick
);
561 serv
->dont_use_proxy
= (net
->flags
& FLAG_USE_PROXY
) ? FALSE
: TRUE
;
564 serv
->use_ssl
= (net
->flags
& FLAG_USE_SSL
) ? TRUE
: FALSE
;
565 serv
->accept_invalid_cert
=
566 (net
->flags
& FLAG_ALLOW_INVALID
) ? TRUE
: FALSE
;
571 port
= strrchr (ircserv
->hostname
, '/');
576 /* support "+port" to indicate SSL (like mIRC does) */
580 serv
->use_ssl
= TRUE
;
582 serv
->connect (serv
, ircserv
->hostname
, atoi (port
+ 2), FALSE
);
585 serv
->connect (serv
, ircserv
->hostname
, atoi (port
+ 1), FALSE
);
590 serv
->connect (serv
, ircserv
->hostname
, -1, FALSE
);
592 server_set_encoding (serv
, net
->encoding
);
596 servlist_connect_by_netname (session
*sess
, char *network
, gboolean join
)
599 GSList
*list
= network_list
;
605 if (strcasecmp (net
->name
, network
) == 0)
607 servlist_connect (sess
, net
, join
);
618 servlist_have_auto (void)
620 GSList
*list
= network_list
;
627 if (net
->flags
& FLAG_AUTO_CONNECT
)
637 servlist_auto_connect (session
*sess
)
639 GSList
*list
= network_list
;
647 if (net
->flags
& FLAG_AUTO_CONNECT
)
649 servlist_connect (sess
, net
, TRUE
);
660 servlist_cycle_cb (server
*serv
)
664 PrintTextf (serv
->server_session
,
665 _("Cycling to next server in %s...\n"), ((ircnet
*)serv
->network
)->name
);
666 servlist_connect (serv
->server_session
, serv
->network
, TRUE
);
673 servlist_cycle (server
*serv
)
681 max
= g_slist_length (net
->servlist
);
684 /* try the next server, if that option is on */
685 if (net
->flags
& FLAG_CYCLE
)
688 if (net
->selected
>= max
)
692 del
= prefs
.recon_delay
* 1000;
694 del
= 500; /* so it doesn't block the gui */
697 serv
->recondelay_tag
= fe_timeout_add (del
, servlist_cycle_cb
, serv
);
699 servlist_connect (serv
->server_session
, net
, TRUE
);
709 servlist_server_find (ircnet
*net
, char *name
, int *pos
)
711 GSList
*list
= net
->servlist
;
718 if (strcmp (serv
->hostname
, name
) == 0)
731 /* find a network (e.g. (ircnet *) to "FreeNode") from a hostname
732 (e.g. "irc.eu.freenode.net") */
735 servlist_net_find_from_server (char *server_name
)
737 GSList
*list
= network_list
;
746 slist
= net
->servlist
;
750 if (strcasecmp (serv
->hostname
, server_name
) == 0)
762 servlist_net_find (char *name
, int *pos
, int (*cmpfunc
) (const char *, const char *))
764 GSList
*list
= network_list
;
771 if (cmpfunc (net
->name
, name
) == 0)
785 servlist_server_add (ircnet
*net
, char *name
)
789 serv
= malloc (sizeof (ircserver
));
790 memset (serv
, 0, sizeof (ircserver
));
791 serv
->hostname
= strdup (name
);
793 net
->servlist
= g_slist_append (net
->servlist
, serv
);
799 servlist_server_remove (ircnet
*net
, ircserver
*serv
)
801 free (serv
->hostname
);
803 net
->servlist
= g_slist_remove (net
->servlist
, serv
);
807 servlist_server_remove_all (ircnet
*net
)
811 while (net
->servlist
)
813 serv
= net
->servlist
->data
;
814 servlist_server_remove (net
, serv
);
819 free_and_clear (char *str
)
830 /* executed on exit: Clear any password strings */
833 servlist_cleanup (void)
838 for (list
= network_list
; list
; list
= list
->next
)
841 free_and_clear (net
->pass
);
846 servlist_net_remove (ircnet
*net
)
851 servlist_server_remove_all (net
);
852 network_list
= g_slist_remove (network_list
, net
);
862 free_and_clear (net
->pass
);
864 free (net
->autojoin
);
870 free (net
->encoding
);
879 if (serv
->network
== net
)
880 serv
->network
= NULL
;
886 servlist_net_add (char *name
, char *comment
, int prepend
)
890 net
= malloc (sizeof (ircnet
));
891 memset (net
, 0, sizeof (ircnet
));
892 net
->name
= strdup (name
);
893 /* net->comment = strdup (comment);*/
894 net
->flags
= FLAG_CYCLE
| FLAG_USE_GLOBAL
| FLAG_USE_PROXY
;
897 network_list
= g_slist_prepend (network_list
, net
);
899 network_list
= g_slist_append (network_list
, net
);
905 servlist_load_defaults (void)
914 net
= servlist_net_add (def
[i
].network
, def
[i
].host
, FALSE
);
915 net
->encoding
= strdup ("UTF-8 (Unicode)");
917 net
->autojoin
= strdup (def
[i
].channel
);
920 free (net
->encoding
);
921 net
->encoding
= strdup (def
[i
].charset
);
923 if (def
[i
].loginmode
)
925 net
->logintype
= def
[i
].loginmode
;
927 if (g_str_hash (def
[i
].network
) == 0x8e1b96f7)
928 prefs
.slist_select
= j
;
932 servlist_server_add (net
, def
[i
].host
);
933 if (!def
[i
+1].host
&& !def
[i
+1].network
)
949 fp
= xchat_fopen_file ("servlist_.conf", "r", 0);
953 while (fgets (buf
, sizeof (buf
) - 2, fp
))
957 buf
[len
-1] = 0; /* remove the trailing \n */
963 net
->nick
= strdup (buf
+ 2);
966 net
->nick2
= strdup (buf
+ 2);
969 net
->user
= strdup (buf
+ 2);
972 net
->real
= strdup (buf
+ 2);
975 net
->pass
= strdup (buf
+ 2);
978 net
->autojoin
= strdup (buf
+ 2);
983 /* concat extra commands with a \n separator */
985 net
->command
= malloc (strlen (tmp
) + strlen (buf
+ 2) + 2);
986 strcpy (net
->command
, tmp
);
987 strcat (net
->command
, "\n");
988 strcat (net
->command
, buf
+ 2);
991 net
->command
= strdup (buf
+ 2);
994 net
->flags
= atoi (buf
+ 2);
997 net
->selected
= atoi (buf
+ 2);
1000 net
->encoding
= strdup (buf
+ 2);
1002 case 'S': /* new server/hostname for this network */
1003 servlist_server_add (net
, buf
+ 2);
1006 net
->logintype
= atoi (buf
+ 2);
1011 net
= servlist_net_add (buf
+ 2, /* comment */ NULL
, FALSE
);
1019 servlist_init (void)
1022 if (!servlist_load ())
1023 servlist_load_defaults ();
1026 /* check if a charset is known by Iconv */
1028 servlist_check_encoding (char *charset
)
1033 c
= strchr (charset
, ' ');
1037 if (!strcasecmp (charset
, "IRC")) /* special case */
1044 gic
= g_iconv_open (charset
, "UTF-8");
1049 if (gic
!= (GIConv
)-1)
1051 g_iconv_close (gic
);
1059 servlist_write_ccmd (char *str
, void *fp
)
1061 return fprintf (fp
, "C=%s\n", (str
[0] == '/') ? str
+ 1 : str
);
1066 servlist_save (void)
1076 snprintf (buf
, sizeof (buf
), "%s/servlist_.conf", get_xdir_fs ());
1077 if (access (buf
, F_OK
) != 0)
1080 fp
= xchat_fopen_file ("servlist_.conf", "w", 0);
1087 fprintf (fp
, "v="PACKAGE_VERSION
"\n\n");
1089 list
= network_list
;
1094 fprintf (fp
, "N=%s\n", net
->name
);
1096 fprintf (fp
, "I=%s\n", net
->nick
);
1098 fprintf (fp
, "i=%s\n", net
->nick2
);
1100 fprintf (fp
, "U=%s\n", net
->user
);
1102 fprintf (fp
, "R=%s\n", net
->real
);
1104 fprintf (fp
, "P=%s\n", net
->pass
);
1106 fprintf (fp
, "J=%s\n", net
->autojoin
);
1108 fprintf (fp
, "L=%d\n", net
->logintype
);
1109 if (net
->encoding
&& strcasecmp (net
->encoding
, "System") &&
1110 strcasecmp (net
->encoding
, "System default"))
1112 fprintf (fp
, "E=%s\n", net
->encoding
);
1113 if (!servlist_check_encoding (net
->encoding
))
1115 snprintf (buf
, sizeof (buf
), _("Warning: \"%s\" character set is unknown. No conversion will be applied for network %s."),
1116 net
->encoding
, net
->name
);
1117 fe_message (buf
, FE_MSG_WARN
);
1122 token_foreach (net
->command
, '\n', servlist_write_ccmd
, fp
);
1124 fprintf (fp
, "F=%d\nD=%d\n", net
->flags
, net
->selected
);
1126 hlist
= net
->servlist
;
1130 fprintf (fp
, "S=%s\n", serv
->hostname
);
1131 hlist
= hlist
->next
;
1134 if (fprintf (fp
, "\n") < 1)
1148 joinlist_free1 (GSList
*list
)
1150 GSList
*head
= list
;
1152 for (; list
; list
= list
->next
)
1153 g_free (list
->data
);
1154 g_slist_free (head
);
1158 joinlist_free (GSList
*channels
, GSList
*keys
)
1160 joinlist_free1 (channels
);
1161 joinlist_free1 (keys
);
1165 joinlist_is_in_list (server
*serv
, char *channel
)
1167 GSList
*channels
, *keys
;
1170 if (!serv
->network
|| !((ircnet
*)serv
->network
)->autojoin
)
1173 joinlist_split (((ircnet
*)serv
->network
)->autojoin
, &channels
, &keys
);
1175 for (list
= channels
; list
; list
= list
->next
)
1177 if (serv
->p_cmp (list
->data
, channel
) == 0)
1181 joinlist_free (channels
, keys
);
1187 joinlist_merge (GSList
*channels
, GSList
*keys
)
1189 GString
*out
= g_string_new (NULL
);
1193 for (; channels
; channels
= channels
->next
)
1195 g_string_append (out
, channels
->data
);
1198 g_string_append_c (out
, ',');
1201 /* count number of REAL keys */
1202 for (i
= 0, list
= keys
; list
; list
= list
->next
)
1208 g_string_append_c (out
, ' ');
1210 for (j
= 0; keys
; keys
= keys
->next
)
1214 g_string_append (out
, keys
->data
);
1221 g_string_append_c (out
, ',');
1225 return g_string_free (out
, FALSE
);
1229 joinlist_split (char *autojoin
, GSList
**channels
, GSList
**keys
)
1231 char *parta
, *partb
;
1238 /* after the first space, the keys begin */
1240 partb
= strchr (autojoin
, ' ');
1251 while (parta
[0] != 0 && parta
[0] != ',' && parta
[0] != ' ')
1259 while (partb
[0] != 0 && partb
[0] != ',' && partb
[0] != ' ')
1268 *channels
= g_slist_append (*channels
, g_strndup (chan
, len
));
1271 *keys
= g_slist_append (*keys
, len
? g_strndup (key
, len
) : NULL
);
1273 if (parta
[0] == ' ' || parta
[0] == 0)
1279 if (partb
[0] == 0 || partb
[0] == ' ')
1280 partb
= NULL
; /* no more keys, but maybe more channels? */
1287 GSList
*lista
, *listb
;
1296 printf("%d. |%s| |%s|\n", i
, lista
->data
, listb
->data
);
1298 lista
= lista
->next
;
1299 listb
= listb
->next
;
1301 printf("-----\n\n");