ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_help.c
(Generate patch)

Comparing ircd-hybrid/trunk/modules/m_help.c (file contents):
Revision 1996 by michael, Fri Apr 19 19:50:27 2013 UTC vs.
Revision 1997 by michael, Sat May 11 17:35:07 2013 UTC

# Line 34 | Line 34
34  
35   #define HELPLEN 400
36  
37 static void dohelp(struct Client *, const char *, char *);
38 static void sendhelpfile(struct Client *, const char *, const char *);
37  
40
41 /*
42 * m_help - HELP message handler
43 *      parv[0] = sender prefix
44 */
38   static void
39 < m_help(struct Client *client_p, struct Client *source_p,
47 <       int parc, char *parv[])
39 > sendhelpfile(struct Client *source_p, const char *path, const char *topic)
40   {
41 <  static time_t last_used = 0;
41 >  FILE *file;
42 >  char line[HELPLEN];
43  
44 <  /* HELP is always local */
52 <  if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
44 >  if ((file = fopen(path, "r")) == NULL)
45    {
46 <    /* safe enough to give this on a local connect only */
47 <    sendto_one(source_p,form_str(RPL_LOAD2HI),
56 <               me.name, source_p->name);
46 >    sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
47 >               me.name, source_p->name, topic);
48      return;
49    }
50  
51 <  last_used = CurrentTime;
51 >  if (fgets(line, sizeof(line), file) == NULL)
52 >  {
53 >    sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
54 >               me.name, source_p->name, topic);
55 >    return;
56 >  }
57  
58 <  dohelp(source_p, UHPATH, parv[1]);
59 < }
58 >  line[strlen(line) - 1] = '\0';
59 >  sendto_one(source_p, form_str(RPL_HELPSTART),
60 >             me.name, source_p->name, topic, line);
61  
62 < /*
63 < * mo_help - HELP message handler
64 < *      parv[0] = sender prefix
68 < */
69 < static void
70 < mo_help(struct Client *client_p, struct Client *source_p,
71 <        int parc, char *parv[])
72 < {
73 <  dohelp(source_p, HPATH, parv[1]);
74 < }
62 >  while (fgets(line, sizeof(line), file))
63 >  {
64 >    line[strlen(line) - 1] = '\0';
65  
66 < /*
67 < * mo_uhelp - HELP message handler
68 < * This is used so that opers can view the user help file without deopering
69 < *      parv[0] = sender prefix
70 < */
71 < static void
72 < mo_uhelp(struct Client *client_p, struct Client *source_p,
83 <            int parc, char *parv[])
84 < {
85 <  dohelp(source_p, UHPATH, parv[1]);
66 >    sendto_one(source_p, form_str(RPL_HELPTXT),
67 >               me.name, source_p->name, topic, line);
68 >  }
69 >
70 >  fclose(file);
71 >  sendto_one(source_p, form_str(RPL_ENDOFHELP),
72 >             me.name, source_p->name, topic);
73   }
74  
75   static void
# Line 132 | Line 119 | dohelp(struct Client *source_p, const ch
119    sendhelpfile(source_p, path, topic);
120   }
121  
122 < static void
123 < sendhelpfile(struct Client *source_p, const char *path, const char *topic)
122 > /*
123 > * m_help - HELP message handler
124 > *      parv[0] = sender prefix
125 > */
126 > static void
127 > m_help(struct Client *client_p, struct Client *source_p,
128 >       int parc, char *parv[])
129   {
130 <  FILE *file;
139 <  char line[HELPLEN];
140 <
141 <  if ((file = fopen(path, "r")) == NULL)
142 <  {
143 <    sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
144 <               me.name, source_p->name, topic);
145 <    return;
146 <  }
130 >  static time_t last_used = 0;
131  
132 <  if (fgets(line, sizeof(line), file) == NULL)
132 >  /* HELP is always local */
133 >  if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
134    {
135 <    sendto_one(source_p, form_str(ERR_HELPNOTFOUND),
136 <               me.name, source_p->name, topic);
135 >    /* safe enough to give this on a local connect only */
136 >    sendto_one(source_p,form_str(RPL_LOAD2HI),
137 >               me.name, source_p->name);
138      return;
139    }
140  
141 <  line[strlen(line) - 1] = '\0';
156 <  sendto_one(source_p, form_str(RPL_HELPSTART),
157 <             me.name, source_p->name, topic, line);
141 >  last_used = CurrentTime;
142  
143 <  while (fgets(line, sizeof(line), file))
144 <  {
161 <    line[strlen(line) - 1] = '\0';
143 >  dohelp(source_p, UHPATH, parv[1]);
144 > }
145  
146 <    sendto_one(source_p, form_str(RPL_HELPTXT),
147 <               me.name, source_p->name, topic, line);
148 <  }
146 > /*
147 > * mo_help - HELP message handler
148 > *      parv[0] = sender prefix
149 > */
150 > static void
151 > mo_help(struct Client *client_p, struct Client *source_p,
152 >        int parc, char *parv[])
153 > {
154 >  dohelp(source_p, HPATH, parv[1]);
155 > }
156  
157 <  fclose(file);
158 <  sendto_one(source_p, form_str(RPL_ENDOFHELP),
159 <             me.name, source_p->name, topic);
157 > /*
158 > * mo_uhelp - HELP message handler
159 > * This is used so that opers can view the user help file without deopering
160 > *      parv[0] = sender prefix
161 > */
162 > static void
163 > mo_uhelp(struct Client *client_p, struct Client *source_p,
164 >         int parc, char *parv[])
165 > {
166 >  dohelp(source_p, UHPATH, parv[1]);
167   }
168  
169   static struct Message help_msgtab = {

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)