summaryrefslogtreecommitdiff
path: root/src/core/chat-protocols.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-09-30 22:49:48 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-09-30 22:49:48 +0000
commit2b8580c8a73ecdb2846b745c32b0ba51be4458e3 (patch)
tree04a68511ca0e66618883afb9e8ff83ca4425f972 /src/core/chat-protocols.c
parent965def294b3787052a9285ef22d6b01cd41a2ebe (diff)
downloadirssi-2b8580c8a73ecdb2846b745c32b0ba51be4458e3.zip
multiprotocol updates. SILC prints channel and private messages now
using the same message formats as IRC. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@699 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/chat-protocols.c')
-rw-r--r--src/core/chat-protocols.c61
1 files changed, 14 insertions, 47 deletions
diff --git a/src/core/chat-protocols.c b/src/core/chat-protocols.c
index a5537f88..40413682 100644
--- a/src/core/chat-protocols.c
+++ b/src/core/chat-protocols.c
@@ -23,9 +23,7 @@
typedef struct {
int id;
- char *name;
- char *fullname;
- char *chatnet;
+ CHAT_PROTOCOL_REC *rec;
} PROTOCOL_REC;
static int id_counter;
@@ -47,7 +45,7 @@ static PROTOCOL_REC *chat_protocol_find(const char *name)
for (tmp = protocols; tmp != NULL; tmp = tmp->next) {
PROTOCOL_REC *rec = tmp->data;
- if (g_strcasecmp(rec->name, name) == 0)
+ if (g_strcasecmp(rec->rec->name, name) == 0)
return rec;
}
@@ -71,25 +69,19 @@ static PROTOCOL_REC *chat_protocol_find_id(int id)
}
/* Register new chat protocol. */
-void chat_protocol_register(const char *name,
- const char *fullname,
- const char *chatnet)
+void chat_protocol_register(CHAT_PROTOCOL_REC *rec)
{
- PROTOCOL_REC *rec;
+ PROTOCOL_REC *proto;
- g_return_if_fail(name != NULL);
- g_return_if_fail(fullname != NULL);
- g_return_if_fail(chatnet != NULL);
+ g_return_if_fail(rec != NULL);
- if (chat_protocol_find(name) != NULL)
+ if (chat_protocol_find(rec->name) != NULL)
return;
- rec = g_new0(PROTOCOL_REC, 1);
- rec->id = ++id_counter;
- rec->name = g_strdup(name);
- rec->fullname = g_strdup(fullname);
- rec->chatnet = g_strdup(chatnet);
- protocols = g_slist_append(protocols, rec);
+ proto = g_new0(PROTOCOL_REC, 1);
+ proto->id = ++id_counter;
+ proto->rec = rec;
+ protocols = g_slist_append(protocols, proto);
}
static void chat_protocol_destroy(PROTOCOL_REC *rec)
@@ -97,10 +89,7 @@ static void chat_protocol_destroy(PROTOCOL_REC *rec)
g_return_if_fail(rec != NULL);
protocols = g_slist_remove(protocols, rec);
-
- g_free(rec->name);
- g_free(rec->fullname);
- g_free(rec->chatnet);
+ g_free(rec->rec);
g_free(rec);
}
@@ -126,37 +115,15 @@ int chat_protocol_lookup(const char *name)
return rec == NULL ? -1 : rec->id;
}
-/* Return the name for the specified chat protocol ID. */
-const char *chat_protocol_get_name(int id)
-{
- PROTOCOL_REC *rec;
-
- g_return_val_if_fail(id > 0, NULL);
-
- rec = chat_protocol_find_id(id);
- return rec == NULL ? NULL : rec->name;
-}
-
-/* Return the full name for the specified chat protocol ID. */
-const char *chat_protocol_get_fullname(int id)
-{
- PROTOCOL_REC *rec;
-
- g_return_val_if_fail(id > 0, NULL);
-
- rec = chat_protocol_find_id(id);
- return rec == NULL ? NULL : rec->fullname;
-}
-
-/* Return the chatnet identifier name for the specified chat protocol ID. */
-const char *chat_protocol_get_chatnet(int id)
+/* Return the record for the specified chat protocol ID. */
+CHAT_PROTOCOL_REC *chat_protocol_get_rec(int id)
{
PROTOCOL_REC *rec;
g_return_val_if_fail(id > 0, NULL);
rec = chat_protocol_find_id(id);
- return rec == NULL ? NULL : rec->chatnet;
+ return rec == NULL ? NULL : rec->rec;
}
void chat_protocols_init(void)