diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-05-31 20:54:28 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-05-31 20:54:28 +0000 |
commit | 7dd1e4c01142f8e20606218e69d37bb3f33806c8 (patch) | |
tree | b358dd65a9dcc4b6fbfff8e08d78b1bddf07ab60 /src | |
parent | e0b160d6a3bbe88509802d5b67537badc736e2e1 (diff) |
- Cleanup flattened links code
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2157 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'src')
-rw-r--r-- | src/ircd.c | 4 | ||||
-rw-r--r-- | src/message.c | 12 | ||||
-rw-r--r-- | src/s_serv.c | 59 |
3 files changed, 20 insertions, 55 deletions
@@ -306,10 +306,6 @@ initialize_global_set_options(void) static void initialize_message_files(void) { - init_message_file(USER_LINKS, LIPATH, &ConfigFileEntry.linksfile); - - read_message_file(&ConfigFileEntry.linksfile); - init_isupport(); } diff --git a/src/message.c b/src/message.c index 716cf8d..3ac3ad4 100644 --- a/src/message.c +++ b/src/message.c @@ -71,18 +71,6 @@ send_message_file(struct Client *source_p, MessageFile *motdToPrint) switch (msgType) { - case USER_LINKS: - if (motdToPrint->contentsOfFile != NULL) - { - for (linePointer = motdToPrint->contentsOfFile; linePointer; - linePointer = linePointer->next) - { - sendto_one(source_p, ":%s 364 %s %s", /* XXX */ - from, to, linePointer->line); - } - } - break; - case ISSUPPORT: if (motdToPrint->contentsOfFile != NULL) { diff --git a/src/s_serv.c b/src/s_serv.c index 4ca292d..2606204 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -54,6 +54,7 @@ #define MIN_CONN_FREQ 300 +dlink_list flatten_links; static dlink_list cap_list = { NULL, NULL, 0 }; static void server_burst(struct Client *); static void burst_all(struct Client *); @@ -72,68 +73,48 @@ static void burst_members(struct Client *, struct Channel *); * but in no particular order. */ void -write_links_file(void* notused) +write_links_file(void *notused) { - MessageFileLine *next_mptr = NULL; - MessageFileLine *mptr = NULL; - MessageFileLine *currentMessageLine = NULL; - MessageFileLine *newMessageLine = NULL; - MessageFile *MessageFileptr = &ConfigFileEntry.linksfile; - FILE *file; - char buff[512]; - dlink_node *ptr; + FILE *file = NULL; + dlink_node *ptr = NULL, *ptr_next = NULL;; + char buff[IRCD_BUFSIZE] = { '\0' }; - if ((file = fopen(MessageFileptr->fileName, "w")) == NULL) + if ((file = fopen(LIPATH, "w")) == NULL) return; - for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr) + DLINK_FOREACH_SAFE(ptr, ptr_next, flatten_links.head) { - next_mptr = mptr->next; - MyFree(mptr); + dlinkDelete(ptr, &flatten_links); + MyFree(ptr->data); + free_dlink_node(ptr); } - MessageFileptr->contentsOfFile = NULL; - DLINK_FOREACH(ptr, global_serv_list.head) { const struct Client *target_p = ptr->data; - /* skip ourselves, we send ourselves in /links */ - if (IsMe(target_p)) - continue; - - /* skip hidden servers */ - if (IsHidden(target_p)) + /* + * Skip hidden servers, aswell as ourselves, since we already send + * ourselves in /links + */ + if (IsHidden(target_p) || IsMe(target_p)) continue; if (HasFlag(target_p, FLAGS_SERVICE) && ConfigServerHide.hide_services) continue; - newMessageLine = MyMalloc(sizeof(MessageFileLine)); - /* * Attempt to format the file in such a way it follows the usual links output * ie "servername uplink :hops info" * Mostly for aesthetic reasons - makes it look pretty in mIRC ;) * - madmax */ - snprintf(newMessageLine->line, sizeof(newMessageLine->line), "%s %s :1 %s", - target_p->name, me.name, target_p->info); - - if (MessageFileptr->contentsOfFile) - { - if (currentMessageLine) - currentMessageLine->next = newMessageLine; - currentMessageLine = newMessageLine; - } - else - { - MessageFileptr->contentsOfFile = newMessageLine; - currentMessageLine = newMessageLine; - } + snprintf(buff, sizeof(buff), "%s %s :1 %s", target_p->name, + me.name, target_p->info); + dlinkAdd(xstrdup(buff), make_dlink_node(), &flatten_links); + snprintf(buff, sizeof(buff), "%s %s :1 %s\n", target_p->name, + me.name, target_p->info); - snprintf(buff, sizeof(buff), "%s %s :1 %s\n", - target_p->name, me.name, target_p->info); fputs(buff, file); } |