diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-02 18:08:36 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-02 18:08:36 +0000 |
commit | 5187dcb6b84e2bdc174caa8ce6331a474a8f2535 (patch) | |
tree | 377ed927190acfee1424a6fca304a2669923821c | |
parent | 7dd1e4c01142f8e20606218e69d37bb3f33806c8 (diff) |
- Cleanup ISUPPORT code and get rid of message.c
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2158 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r-- | include/conf.h | 1 | ||||
-rw-r--r-- | include/message.h | 62 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/Makefile.in | 8 | ||||
-rw-r--r-- | src/ircd.c | 15 | ||||
-rw-r--r-- | src/message.c | 233 | ||||
-rw-r--r-- | src/s_user.c | 26 |
7 files changed, 20 insertions, 326 deletions
diff --git a/include/conf.h b/include/conf.h index 250efd5..b96f815 100644 --- a/include/conf.h +++ b/include/conf.h @@ -26,7 +26,6 @@ #define INCLUDED_s_conf_h #include "config.h" #include "ircd_defs.h" -#include "message.h" /* MessageFile */ #include "client.h" #include "hook.h" #include "conf_class.h" diff --git a/include/message.h b/include/message.h deleted file mode 100644 index ea6b97b..0000000 --- a/include/message.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). - * motd.h: A header for the MOTD functions. - * - * Copyright (C) 2002 by the past and present ircd coders, and others. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - * - * $Id: motd.h 1737 2013-01-14 17:37:55Z michael $ - */ - -#ifndef INCLUDED_message_h -#define INCLUDED_message_h -#include "ircd_defs.h" - - -#define MESSAGELINELEN 256 - -struct MessageFileLine -{ - struct MessageFileLine *next; - char line[MESSAGELINELEN + 1]; -}; - -typedef struct MessageFileLine MessageFileLine; - -typedef enum { - ISSUPPORT -} MessageType; - -struct MessageFile -{ - MessageFileLine *contentsOfFile; - MessageType msgType; - char fileName[HYB_PATH_MAX + 1]; -}; - -typedef struct MessageFile MessageFile; - -struct Client; - -extern void init_message_file(MessageType, const char *, MessageFile *); -extern int send_message_file(struct Client *, MessageFile *); -extern int read_message_file(MessageFile *); -extern MessageFile *init_MessageLine(void); -extern void addto_MessageLine(MessageFile *, const char *); -extern void destroy_MessageLine(MessageFile *); - -#endif /* INCLUDED_motd_h */ diff --git a/src/Makefile.am b/src/Makefile.am index f119469..ae67d4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,7 +35,6 @@ ircd_SOURCES = channel.c \ match.c \ memory.c \ mempool.c \ - message.c \ modules.c \ motd.c \ rng_mt.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 8773dcc..0c3cc49 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -103,9 +103,9 @@ am_ircd_OBJECTS = channel.$(OBJEXT) channel_mode.$(OBJEXT) \ irc_string.$(OBJEXT) ircd.$(OBJEXT) ircd_signal.$(OBJEXT) \ list.$(OBJEXT) listener.$(OBJEXT) log.$(OBJEXT) \ match.$(OBJEXT) memory.$(OBJEXT) mempool.$(OBJEXT) \ - message.$(OBJEXT) modules.$(OBJEXT) motd.$(OBJEXT) \ - rng_mt.$(OBJEXT) numeric.$(OBJEXT) packet.$(OBJEXT) \ - parse.$(OBJEXT) s_bsd_epoll.$(OBJEXT) s_bsd_poll.$(OBJEXT) \ + modules.$(OBJEXT) motd.$(OBJEXT) rng_mt.$(OBJEXT) \ + numeric.$(OBJEXT) packet.$(OBJEXT) parse.$(OBJEXT) \ + s_bsd_epoll.$(OBJEXT) s_bsd_poll.$(OBJEXT) \ s_bsd_devpoll.$(OBJEXT) s_bsd_kqueue.$(OBJEXT) \ s_bsd_select.$(OBJEXT) restart.$(OBJEXT) resv.$(OBJEXT) \ rsa.$(OBJEXT) s_auth.$(OBJEXT) s_bsd.$(OBJEXT) \ @@ -374,7 +374,6 @@ ircd_SOURCES = channel.c \ match.c \ memory.c \ mempool.c \ - message.c \ modules.c \ motd.c \ rng_mt.c \ @@ -523,7 +522,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/match.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempool.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/message.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modules.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric.Po@am__quote@ @@ -56,7 +56,6 @@ #include "mempool.h" #include "hook.h" #include "ircd_getopt.h" -#include "message.h" #include "supported.h" #include "watch.h" #include "conf_db.h" @@ -297,18 +296,6 @@ initialize_global_set_options(void) /* End of global set options */ } -/* initialize_message_files() - * - * inputs - none - * output - none - * side effects - Set up all message files needed, motd etc. - */ -static void -initialize_message_files(void) -{ - init_isupport(); -} - /* initialize_server_capabs() * * inputs - none @@ -540,7 +527,7 @@ main(int argc, char *argv[]) mp_pool_init(); init_dlink_nodes(); - initialize_message_files(); + init_isupport(); dbuf_init(); hash_init(); init_ip_hash_table(); /* client host ip hash table */ diff --git a/src/message.c b/src/message.c deleted file mode 100644 index 3ac3ad4..0000000 --- a/src/message.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). - * motd.c: Message of the day functions. - * - * Copyright (C) 2002 by the past and present ircd coders, and others. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - * - * $Id: motd.c 1834 2013-04-19 19:50:27Z michael $ - */ - -#include "stdinc.h" -#include "list.h" -#include "message.h" -#include "ircd.h" -#include "fdlist.h" -#include "s_bsd.h" -#include "conf.h" -#include "send.h" -#include "numeric.h" -#include "client.h" -#include "irc_string.h" -#include "memory.h" -#include "s_serv.h" - -/* -** init_message_file -** -*/ -void -init_message_file(MessageType msgType, const char *fileName, MessageFile *msg) -{ - strlcpy(msg->fileName, fileName, sizeof(msg->fileName)); - msg->msgType = msgType; - msg->contentsOfFile = NULL; -} - -/* -** send_message_file -** -** This function split off so a server notice could be generated on a -** user requested motd, but not on each connecting client. -*/ -int -send_message_file(struct Client *source_p, MessageFile *motdToPrint) -{ - MessageFileLine *linePointer; - MessageType msgType; - const char *from, *to; - - if (motdToPrint == NULL) - return(-1); - - msgType = motdToPrint->msgType; - - from = ID_or_name(&me, source_p->from); - to = ID_or_name(source_p, source_p->from); - - switch (msgType) - { - case ISSUPPORT: - if (motdToPrint->contentsOfFile != NULL) - { - for (linePointer = motdToPrint->contentsOfFile; linePointer; - linePointer = linePointer->next) - { - sendto_one(source_p, form_str(RPL_ISUPPORT), - me.name, source_p->name, linePointer->line); - } - } - break; - - default: - break; - } - - return(0); -} - -/* - * read_message_file() - original From CoMSTuD, added Aug 29, 1996 - * - * inputs - pointer to MessageFileptr - * output - - * side effects - - */ -int -read_message_file(MessageFile *MessageFileptr) -{ - /* used to clear out old MessageFile entries */ - MessageFileLine *mptr = 0; - MessageFileLine *next_mptr = 0; - - /* used to add new MessageFile entries */ - MessageFileLine *newMessageLine = 0; - MessageFileLine *currentMessageLine = 0; - - char buffer[MESSAGELINELEN]; - char *p; - FILE *file; - - for (mptr = MessageFileptr->contentsOfFile; mptr; mptr = next_mptr) - { - next_mptr = mptr->next; - MyFree(mptr); - } - - MessageFileptr->contentsOfFile = NULL; - - if ((file = fopen(MessageFileptr->fileName, "r")) == NULL) - return(-1); - - while (fgets(buffer, sizeof(buffer), file)) - { - if ((p = strchr(buffer, '\n')) != NULL) - *p = '\0'; - - newMessageLine = (MessageFileLine *)MyMalloc(sizeof(MessageFileLine)); - strlcpy(newMessageLine->line, buffer, sizeof(newMessageLine->line)); - newMessageLine->next = NULL; - - if (MessageFileptr->contentsOfFile != NULL) - { - if (currentMessageLine) - currentMessageLine->next = newMessageLine; - - currentMessageLine = newMessageLine; - } - else - { - MessageFileptr->contentsOfFile = newMessageLine; - currentMessageLine = newMessageLine; - } - } - - fclose(file); - return(0); -} - -/* - * init_MessageLine - * - * inputs - NONE - * output - pointer to new MessageFile - * side effects - Use this when an internal Message File is wanted - * without reading an actual file. The MessageFile - * is init'ed, but must have content added to it through - * addto_MessageLine() - */ - -MessageFile * -init_MessageLine(void) -{ - MessageFile *mf; - MessageFileLine *mptr = NULL; - - mf = MyMalloc(sizeof(MessageFile)); - mf->msgType = ISSUPPORT; /* XXX maybe pass it alone in args? */ - mptr = MyMalloc(sizeof(MessageFileLine)); - mf->contentsOfFile = mptr; - return(mf); -} - -/* - * addto_MessageLine - * - * inputs - Pointer to existing MessageFile - * - New string to add to this MessageFile - * output - NONE - * side effects - Use this when an internal MessageFile is wanted - * without reading an actual file. Content is added - * to this MessageFile through this function. - */ - -void -addto_MessageLine(MessageFile *mf, const char *str) -{ - MessageFileLine *mptr = mf->contentsOfFile; - MessageFileLine *nmptr = NULL; - - if (mptr == NULL) - { - mptr = MyMalloc(sizeof(MessageFileLine)); - strcpy(mptr->line, str); - mf->contentsOfFile = mptr; - } - else - { - while (mptr->next != NULL) - mptr = mptr->next; - nmptr = MyMalloc(sizeof(MessageFileLine)); - strcpy(nmptr->line, str); - mptr->next = nmptr; - } -} - -/* - * destroy_MessageLine(MessageFile *mf) - * - * inputs - pointer to the MessageFile to destroy - * output - NONE - * side effects - All the MessageLines attached to the given mf - * Are freed then one MessageLine is recreated - */ -void -destroy_MessageLine(MessageFile *mf) -{ - MessageFileLine *mptr = mf->contentsOfFile; - MessageFileLine *nmptr = NULL; - - if (mptr == NULL) - return; - - for (mptr = mf->contentsOfFile; mptr != NULL; mptr = nmptr) - { - nmptr = mptr->next; - MyFree(mptr); - } - mf->contentsOfFile = NULL; -} diff --git a/src/s_user.c b/src/s_user.c index e480da3..66e188b 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -51,7 +51,6 @@ #include "s_misc.h" #include "parse.h" #include "watch.h" -#include "message.h" static char umode_buffer[IRCD_BUFSIZE]; @@ -73,8 +72,8 @@ struct Isupport int number; }; -static dlink_list support_list = { NULL, NULL, 0 }; -MessageFile *isupportFile; +static dlink_list support_list; +static dlink_list support_list_lines; /* memory is cheap. map 0-255 to equivalent mode */ const unsigned int user_modes[256] = @@ -243,7 +242,11 @@ show_lusers(struct Client *source_p) void show_isupport(struct Client *source_p) { - send_message_file(source_p, isupportFile); + const dlink_node *ptr = NULL; + + DLINK_FOREACH(ptr, support_list_lines.head) + sendto_one(source_p, form_str(RPL_ISUPPORT), me.name, + source_p->name, ptr->data); } /* @@ -1353,8 +1356,6 @@ uid_get(void) void init_isupport(void) { - isupportFile = init_MessageLine(); - add_isupport("CALLERID", NULL, -1); add_isupport("CASEMAPPING", CASEMAP, -1); add_isupport("DEAF", "D", -1); @@ -1450,13 +1451,18 @@ rebuild_isupport_message_line(void) { char isupportbuffer[IRCD_BUFSIZE]; char *p = isupportbuffer; - dlink_node *ptr = NULL; + dlink_node *ptr = NULL, *ptr_next = NULL; int n = 0; int tokens = 0; size_t len = 0; size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT)); - destroy_MessageLine(isupportFile); + DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head) + { + dlinkDelete(ptr, &support_list_lines); + MyFree(ptr->data); + free_dlink_node(ptr); + } DLINK_FOREACH(ptr, support_list.head) { @@ -1486,7 +1492,7 @@ rebuild_isupport_message_line(void) if (*--p == ' ') *p = '\0'; - addto_MessageLine(isupportFile, isupportbuffer); + dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines); p = isupportbuffer; len = 0; n = tokens = 0; @@ -1497,6 +1503,6 @@ rebuild_isupport_message_line(void) { if (*--p == ' ') *p = '\0'; - addto_MessageLine(isupportFile, isupportbuffer); + dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines); } } |