… | |
… | |
82 | int comp; |
82 | int comp; |
83 | int size; |
83 | int size; |
84 | |
84 | |
85 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
85 | sprintf (buf, "%s/%s", settings.confdir, settings.motd); |
86 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
86 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
87 | { |
|
|
88 | return; |
87 | return; |
89 | } |
88 | |
90 | motd[0] = '\0'; |
89 | motd[0] = '\0'; |
91 | size = 0; |
90 | size = 0; |
|
|
91 | |
92 | while (fgets (buf, MAX_BUF, fp) != NULL) |
92 | while (fgets (buf, MAX_BUF, fp) != NULL) |
93 | { |
93 | { |
94 | if (*buf == '#') |
94 | if (*buf == '#') |
95 | continue; |
95 | continue; |
|
|
96 | |
96 | strncat (motd + size, buf, HUGE_BUF - size); |
97 | strncat (motd + size, buf, HUGE_BUF - size); |
97 | size += strlen (buf); |
98 | size += strlen (buf); |
98 | } |
99 | } |
|
|
100 | |
99 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
101 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); |
100 | close_and_delete (fp, comp); |
102 | close_and_delete (fp, comp); |
101 | } |
103 | } |
102 | |
104 | |
103 | void |
105 | void |
… | |
… | |
109 | int comp; |
111 | int comp; |
110 | int size; |
112 | int size; |
111 | |
113 | |
112 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
114 | sprintf (buf, "%s/%s", settings.confdir, settings.rules); |
113 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
115 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
114 | { |
|
|
115 | return; |
116 | return; |
116 | } |
117 | |
117 | rules[0] = '\0'; |
118 | rules[0] = '\0'; |
118 | size = 0; |
119 | size = 0; |
|
|
120 | |
119 | while (fgets (buf, MAX_BUF, fp) != NULL) |
121 | while (fgets (buf, MAX_BUF, fp) != NULL) |
120 | { |
122 | { |
121 | if (*buf == '#') |
123 | if (*buf == '#') |
122 | continue; |
124 | continue; |
|
|
125 | |
123 | if (size + strlen (buf) >= HUGE_BUF) |
126 | if (size + strlen (buf) >= HUGE_BUF) |
124 | { |
127 | { |
125 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
128 | LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); |
126 | break; |
129 | break; |
127 | } |
130 | } |
|
|
131 | |
128 | strncat (rules + size, buf, HUGE_BUF - size); |
132 | strncat (rules + size, buf, HUGE_BUF - size); |
129 | size += strlen (buf); |
133 | size += strlen (buf); |
130 | } |
134 | } |
|
|
135 | |
131 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
136 | draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); |
132 | close_and_delete (fp, comp); |
137 | close_and_delete (fp, comp); |
133 | } |
138 | } |
134 | |
139 | |
135 | void |
140 | void |
… | |
… | |
143 | int size; |
148 | int size; |
144 | |
149 | |
145 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
150 | sprintf (buf, "%s/%s", settings.confdir, settings.news); |
146 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
151 | if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) |
147 | return; |
152 | return; |
|
|
153 | |
148 | news[0] = '\0'; |
154 | news[0] = '\0'; |
149 | subject[0] = '\0'; |
155 | subject[0] = '\0'; |
150 | size = 0; |
156 | size = 0; |
|
|
157 | |
151 | while (fgets (buf, MAX_BUF, fp) != NULL) |
158 | while (fgets (buf, MAX_BUF, fp) != NULL) |
152 | { |
159 | { |
153 | if (*buf == '#') |
160 | if (*buf == '#') |
154 | continue; |
161 | continue; |
|
|
162 | |
155 | if (*buf == '%') |
163 | if (*buf == '%') |
156 | { /* send one news */ |
164 | { /* send one news */ |
157 | if (size > 0) |
165 | if (size > 0) |
158 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
166 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ |
159 | strcpy (subject, buf + 1); |
167 | strcpy (subject, buf + 1); |
… | |
… | |
186 | return 0; |
194 | return 0; |
187 | |
195 | |
188 | for (; *cp != '\0'; cp++) |
196 | for (; *cp != '\0'; cp++) |
189 | if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') |
197 | if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') |
190 | return 0; |
198 | return 0; |
|
|
199 | |
191 | return 1; |
200 | return 1; |
192 | } |
201 | } |
193 | |
202 | |
194 | /* This no longer sets the player map. Also, it now updates |
203 | /* This no longer sets the player map. Also, it now updates |
195 | * all the pointers so the caller doesn't need to do that. |
204 | * all the pointers so the caller doesn't need to do that. |