1 /*
2  This file is part of SLRN.
3 
4  Copyright (c) 1994, 1999 John E. Davis <davis@space.mit.edu>
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the Free
8  Software Foundation; either version 2 of the License, or (at your option)
9  any later version.
10 
11  This program is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14  more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc., 675
18  Mass Ave, Cambridge, MA 02139, USA.
19 */
20 #include "config.h"
21 #include "slrnfeat.h"
22 
23 #include <stdio.h>
24 #include <string.h>
25 
26 #ifdef HAVE_STDLIB_H
27 # include <stdlib.h>
28 #endif
29 
30 #include <slang.h>
31 #include "jdmacros.h"
32 
33 #include "slrn.h"
34 #include "misc.h"
35 #include "util.h"
36 #ifdef KANJI
37 #include "chmap.h"
38 #endif
39 
40 static char *Global_Help [] =
41 {
42    " For more information about slrn, check out the newsgroups:",
43    "   news.software.readers",
44    "   alt.lang.s-lang",
45    " Email bug reports, suggestions, comments to davis@space.mit.edu",
46    "",
47    NULL
48 };
49 
50 #ifdef KANJI
51 /* ����help.c��EUC�ǥ����֤��뤳�ȡ�*/
52 
53 static char *Global_Help_J [] =
54 {
55    " slrn�ˤĤ��Ƥξܤ�������ϡ�news.software.readers �� alt.lang.s-lang ",
56    " �Ȥ����˥塼�����롼�פ��ɤ�Ǥ�������(���ܤǤ�fj.news.reader)��",
57    " �Х���ݡ��ȡ���Ƥ䥳���Ȥ�davis@space.mit.edu�ޤǤɤ���",
58    " (���ܸ��Ǥ˴ؤ��Ƥ�kikutani@galaxy.net�ޤ�)"
59    "",
60    NULL
61 };
62 #endif
63 
64 static char *Art_Help[] =
65 {
66    "Searching:",
67      "  /           Search forward in the article.",
68      "  a           Author search forward.",
69      "  A           Author search backward.",
70      "  s           Subject search forward.",
71      "  S           Subject search backward.",
72      "  =           Skip to next article of specified subject",
73      "  !           Skip to next article with high score",
74      "  ESC-l       Locate header by message-id.",
75      "Commands that affect the article:",
76      "  h           Hide window (zoom header window)",
77      "  SPACE       Select article or scroll to next page",
78      "  DEL, b      Scroll article back one page",
79      "  ESC-UP      Scroll article up one line",
80      "  ESC-DOWN    Scroll article down one line",
81      "  RIGHT       Pan article to the right",
82      "  LEFT        Pan article to the left",
83      "  W           Wrap or Unwrap article",
84      "  t           Toggle on/off the display of unimportant headers.",
85      "  T           Toggle on/off the display of quoted lines.",
86      "  TAB         Skip beyond quoted text.",
87      "  ESC-r       Toggle ROT 13 decryption on and off.",
88      "  g           Skip to next digest article.",
89    "  ESC Ctrl-C  Cancel article (you must be the author).",
90    "  ESC Ctrl-S  Supersede article, allowing you to edit original text.",
91 #if SLRN_HAS_GROUPLENS
92      "  0           Assign article a GroupLens rating.",
93 #endif
94 #if defined(KANJI) && defined(SLRN_HAS_MIME)
95      "  ESC m       Toggle on/off decoding MIME article.",
96 #endif
97      "Posting, Replying, Printing, Piping, and Saving:",
98      "  y           Send the article to the printer",
99      "  P           Post a new article (NOT followup)",
100      "  ESC P       Post or edit a postponed article",
101      "  f           Followup to current article.",
102      "    Note: ESC 1 f ==> all headers will be inserted.",
103      "          ESC 2 f ==> the message will be inserted without quoting.",
104      "  F           Forward the article to someone",
105      "  r           Reply to the poster",
106      "  o           Append the article, thread, or tagged articles to a file",
107      "  :           Decode article, numerically tagged articles, or thread.",
108      "  #           Numerically tag the article for saving/decoding.",
109      "  ESC #       Remove numerical tags.",
110      "  |           Pipe the article to an external command.",
111      "Commands that pertain to the header window:",
112      "  d           Mark article as read and move to next unread.",
113      "  ESC-d       Mark thread as read and move to next unread.",
114      "  u           Mark the article as unread",
115      "  p           Move to a previously unread article",
116      "  n           Move to the next unread article or next group if at end.",
117      "  L           Goto the article that was last read.",
118      "  N           Skip to next news group.",
119      "  UP          Move to the previous article",
120      "  DOWN        Move to the next article",
121      "  ;           Set a mark at current position",
122      "  ,           Return to the previous mark setting mark first",
123      "  q           Quit back to group mode",
124      "  Ctrl-^      Decrease the size of the header window by one line",
125      "  ^           Increase the size of the header window by one line",
126      "  ESC t       Toggle collapse/uncollapse of thread",
127      "    Note: A prefix argument may be used to operate on all threads.",
128      "  ESC >       Move to the end of the header list",
129      "  ESC <       Move to the beginning of the header list",
130      "  Ctrl-U      Perform Page-Up on the header window.",
131      "  Ctrl-D      Perform Page-Dn on the header window.",
132      "  ESC-a       Toggle header display format",
133      "  ESC-s       Select sort mode",
134      "  ESC-p       Find parent header reading from server if necessary",
135      "  ESC 1 ESC p Reconstruct thread.",
136      "  ESC Ctrl-P  Find all children of current header (queries server)",
137      "  c           Catch-up (Mark ALL articles as read).",
138      "  ESC-u       Mark ALL articles as UN-read",
139      "  C           Mark articles TO the current position as read",
140      "  ESC-U       Mark articles TO current position as UN-read",
141      "  K           Create a score entry based on current header.",
142      "  ESC 1 K     Edit score file",
143      "  *           Mark header so it is un-affected by catchup commands.",
144      "  ESC 1 *     Un-mark all headers marked with '*'.",
145      "  x           Remove all read articles from list.",
146      "Miscellaneous:",
147      "  . (Period)  Repeat last key sequence",
148      "  U           Search for URL and follow it",
149      NULL
150 };
151 #ifdef KANJI
152 static char *Art_Help_J[] =
153 {
154    "����:",
155      "  /           ����������������",
156      "  a           ���Ԥ�����������",
157      "  A           ���Ԥθ���������",
158      "  s           ���֥������Ȥ�����������",
159      "  S           ���֥������Ȥθ���������",
160      "  =           ���ꤷ�����֥������ȤǼ��ε����˥����å�",
161      "  !           ���Υϥ��������ε����˥����å�",
162      "  ESC-l       ��å�����ID�ǵ���������",
163      "�����˱ƶ���Ϳ���륳�ޥ��:",
164      "  h           ����������ɤ���(�إå�������ɤ����)",
165      "  SPACE       �����������ޤ��ϼ��Ǥإ�������",
166      "  DEL, b      1�ǥХå���������",
167      "  ESC-UP      ������1�ԥ������륢�å�",
168      "  ESC-DOWN    ������1�ԥ������������",
169      "  RIGHT       �������إѥ�",
170      "  LEFT        �������إѥ�",
171      "  W           �������ޤ꤫�������ɤ����Υȥ���",
172      "  t           ���פǤʤ��إå���ɽ�����뤫�ɤ����Υȥ��롣",
173      "  T           ���Ѥ��줿�Ԥ�ɽ�����뤫�ɤ����Υȥ��롣",
174      "  TAB         ���Ѥ��줿�Ԥβ��˥����åס�",
175      "  ESC-r       ROT 13 �����椹�뤫�ɤ����Υȥ��롣",
176      "  g           ���Ρ֥����������ȵ����פ˥����åס�",
177    "  ESC Ctrl-C  �����Υ������(���ԤǤʤ��Ȥ���)��",
178    "  ESC Ctrl-S  ������ supersede����ȤΥƥ����Ȥ��Խ��Ǥ���",
179 #if SLRN_HAS_GROUPLENS
180      "  0           ������GroupLens�Υ졼�Ȥ��դ��롣",
181 #endif
182 #if defined(SLRN_HAS_MIME) && defined(KANJI)
183      "  ESC m       ������ MIME �Υǥ����ɤΥȥ���",
184 #endif
185      "�ݥ��ȡ���ץ饤���������ѥ��ס�������:",
186      "  y           ������ץ��������",
187      "  P           ���������������(�ե����ǤϤʤ�)",
188      "  ESC P       ���Ȳ��ˤ�����������Ƥޤ����Խ�",
189      "  f           ���ߤε����˥ե�����",
190      "    ��: ESC 1 f ==> �إå��⤹�٤���������롣",
191      "        ESC 2 f ==> ������������ʤ�����������롣",
192      "  F           �����Υե����",
193      "  r           ������ݥ��Ȥ����ͤ˥�ץ饤",
194      "  o           �����䥹��åɡ��ޤ��ϥ������դ���������ե�������ɲä���",
195      "  :           �������ֹ楿�����դ������������뤤�ϥ���åɤ�ǥ����ɤ��롣",
196      "  #           ��¸��ǥ����ɤΤ���˵������ֹ楿�����դ��롣",
197      "  ESC #       �ֹ楿����ä���",
198      "  |           �����������ޥ�ɤ˥ѥ��פǤ錄����",
199      "�إå�������ɥ��˴ؤ��륳�ޥ��:",
200      "  d           �������ɤ�������դ�������̤�ɤ˰�ư��",
201      "  ESC-d       ����åɤ��ɤ�������դ�������̤�ɤ˰�ư��",
202      "  u           �������ɤޤʤ��ä����Ȥˤ���",
203      "  p           ����̤�ɵ����˰�ư",
204      "  n           ����̤�ɵ����˰�ư���롢�⤷�Ǹ�ʤ�м��Υ��롼�פˡ�",
205      "  L           �Ǹ���ɤ�������˰�ư��",
206      "  N           ���Υ˥塼�����롼�פ˥����åס�",
207      "  UP          ���ε����˰�ư",
208      "  DOWN        ���ε����˰�ư",
209      "  ;           ���ߤΰ��֤�ޡ������դ���",
210      "  ,           �ޤ��ޡ������դ��ơ����˥ޡ����������֤����",
211      "  q           ���롼�ץ⡼�ɤ����",
212      "  Ctrl-^ �ޤ���Ctrl-6",
213      "              �إå�������ɥ����Խ̾�",
214      "  ^           �إå�������ɥ����Գ���",
215      "  ESC t       ����åɤΥĥ꡼ɽ���Υȥ���",
216      "    ��: �ץ�ե����������Ϥ��٤ƤΥ���åɤ˺��Ѥ�����Τ˻Ȥ���",
217      "  ESC >       �إå��ꥹ�ȤκǸ�˰�ư",
218      "  ESC <       �إå��ꥹ�Ȥκǽ�˰�ư",
219      "  Ctrl-U      �إå�������ɥ��ǥڡ������åס�",
220      "  Ctrl-D      �إå�������ɥ��ǥڡ���������",
221      "  ESC-a       �إå�ɽ���������ѹ�",
222      "  ESC-s       ��������ˡ������",
223      "  ESC-p       �Ƶ����Υإå���õ����ɬ�פʤ饵���Ф����ɤ�",
224      "  ESC 1 ESC p ����åɤ�ƹ��ۤ���",
225      "  ESC Ctrl-P  ���ߤΥإå��λҵ������٤�õ��(ɬ�פʤ饵���Ф���)",
226      "  c           ����å����å�(���٤Ƥε������ɤ�����Ȥˤ���)��",
227      "  ESC-u       ���٤Ƥε������ɤޤʤ��ä����Ȥˤ���",
228      "  C           ���ߤΰ��֤μ����ޤǤε������ɤ�����Ȥˤ���",
229      "  ESC-U       ���ߤΰ��֤μ����ޤǤε������ɤޤʤ��ä����Ȥˤ���",
230      "  K           ���ߤΥإå����˥���������ȥ���롣��",
231      "  ESC 1 K     �������ե�������Խ����롣",
232      "  *           ����å����åץ��ޥ�ɤ��ƶ����ʤ��ޡ�����إå����դ��롣",
233      "  ESC 1 *     '*'���դ����ޡ������٤ƾä���",
234      "  x           ���ɵ������٤ƥꥹ�Ȥ���ä���",
235      "����¾�Υ��ޥ��:",
236      "  . (�ԥꥪ��)�Ǹ�Υ����������������֤�",
237      "  U           URL��õ���Ƥ�����˹Ԥ�",
238      NULL
239 };
240 #endif
241 
242 static char *Group_Help [] =
243 {
244      " Note: The keys are case sensitive!  That is, 's' and 'S' are not the same.",
245      "       Some commands take a prefix argument.  This means press ESC, then",
246      "       press a digit followed by desired command key sequence.",
247      "",
248      "Subscribing/Unsubscribing Hints:",
249      "  1. Press CAPITAL 'L' and enter the name of the groups to display, e.g.,",
250      "      *.music.*  to see all 'music' groups.",
251      "  2. Move to the group you want to subscribe to and then press 's'.",
252      "      Repeat this step for each group.",
253      "  3. Press the Capital-L key again to display only subscribed groups.",
254      "Commands that affect the current group:",
255      "  P                    Post an article to the current newsgroup",
256      "  ESC P                Post a or edit postponed article",
257      "  SPACE, RETURN        Select the current newsgroup.",
258      "   The following three variations permit viewing previously read articles:",
259      "  ESC 1 SPACE          Select group with article number query.",
260      "  ESC 2 SPACE          Select group but do not apply score.",
261      "  ESC 3 SPACE          Select group with query but do not apply score.",
262      "  s                    Subscribe to the current newsgroup",
263      "  ESC 1 s              Subscribe to pattern",
264      "  u                    Un-subscribe from the current newsgroup",
265      "  ESC 1 u              Un-subscribe to pattern",
266      "  c                    Catchup-- mark all articles as read",
267      "  ESC u                Un-Catchup-- mark all articles as un-read",
268      "Movement Commands:",
269      "  ESC <                Move to top of the list",
270      "  ESC >                Move to bottom of the list",
271      "  Ctrl-V, Ctrl-D       Scroll to next page",
272      "  ESC V, Ctrl-U        Scroll to previous page",
273      "  DOWN                 Move to next group",
274      "  UP                   Move to previous group",
275      "Miscellaneous Commands:",
276      "  a                    Add a new newsgroup (See 'L' help too!)",
277      "  Ctrl-L, Ctrl-R       Redraw the screen.",
278      "  Ctrl-Z               Suspend newsreader.",
279      "  l                    Toggle listing of groups that have no unread articles.",
280      "  L                    Toggle listing of unsubscribed groups.",
281      "  ESC 1 L              Hide unsubscribed groups",
282      "  /                    Group keyword search.  Use 'l' to search hidden groups.",
283      "  q                    Quit newsreader",
284      "  G                    Get new news",
285      "  K                    Toggle scoring mode",
286      "  X                    Force a save of the newsrc file.",
287      "  ESC-a                Toggle display of group description on/off.",
288      "  Ctrl-X Ctrl-T        Transpose position of groups.",
289      "  m                    Move newsgroup to different location.",
290      "  . (Period)           Repeat last key sequence",
291      NULL
292 };
293 
294 #ifdef KANJI
295 static char *Group_Help_J [] =
296 {
297    " ��: ��������ʸ��/��ʸ������̤��ޤ��� �Ĥޤ��s�פȡ�S�פ��̤Τ�ΤǤ���",
298      "     �����Ĥ��Υ��ޥ�ɤǤϡ֥ץ�ե����������פ��Ȥ��ޤ��������ESC",
299      "     �����������Τ��������������������˼¹Ԥ��������ޥ�ɤΥ���",
300      "     ���������������ȤǤ���",
301      "",
302      "�˥塼�����롼�פι��ɤȹ�����ߤˤĤ���:",
303      "  1. ��ʸ����'L'������ɽ�������륰�롼��̾�����Ϥ��롧 ���Ȥ���",
304      "      *.music.* �� 'music' ���դ����٤ƤΥ��롼�פ�ɽ������롣",
305      "  2. ���ɤ��������롼�פ˰�ư����'s'������",
306      "     ���Υ��ƥåפ��줾��Υ��롼�פˤĤ��Ʒ����֤���",
307      "  3. ������Υ��롼�פΤߤ�ɽ�������뤿��˺��١���ʸ����'L'������",
308      "���ߤΥ��롼�פ˱ƶ���Ϳ���륳�ޥ��:",
309      "  P                    ���ߤΥ˥塼�����롼�פ˵��������",
310      "  ESC P                ���Ȳ��ˤ�����������Ƥޤ����Խ�",
311      "  SPACE, RETURN        ���ߤΥ˥塼�����롼�פ������롣",
312      "   ���λ��Ĥη����Ǥϡ��������ɤ���������뤳�Ȥ��Ǥ���:",
313      "  ESC 1 SPACE          ���롼�פ�����������ɤ൭���������Ϥ��롣",
314      "  ESC 2 SPACE          ���롼�פ������������������Ŭ�Ѥ��ʤ���",
315      "  ESC 3 SPACE          ���롼�פ������������������ơ���������Ŭ�Ѥ��ʤ�",
316      "  s                    ���ߤΥ˥塼�����롼�פ���ɤ���",
317      "  ESC 1 s              �ѥ�����ǹ��ɤ���",
318      "  u                    ���ߤΥ˥塼�����롼�פι��ɤ���ߤ���",
319      "  ESC 1 u              �ѥ�����ǹ��ɤ���ߤ���",
320      "  c                    ����å����å�---���٤Ƥε������ɤ�����Ȥˤ���",
321      "  ESC u                ����å����åפε�--���٤Ƥε������ɤޤʤ��ä����Ȥˤ���",
322      "��ư���ޥ��:",
323      "  ESC <                �ꥹ�Ȥκǽ�˰�ư",
324      "  ESC >                �ꥹ�ȤκǸ�˰�ư",
325      "  Ctrl-V, Ctrl-D       ���ڡ����˥�������",
326      "  ESC V, Ctrl-U        ���ڡ����˥�������",
327      "  DOWN                 ���Υ��롼�פ˰�ư",
328      "  UP                   ���Υ��롼�פ˰�ư",
329      "����¾�Υ��ޥ��:",
330      "  a                    ���������롼�פ�ä���('L'�Υإ�פ⻲�ȤΤ���)",
331      "  Ctrl-L, Ctrl-R       ���̺�����",
332      "  Ctrl-Z               �˥塼���꡼�������ڥ��",
333      "  l                    ̤�ɤε������ʤ����롼�פ�ɽ���Υȥ���",
334      "  L                    ���ɤ��Ƥ��ʤ����롼�פ�ɽ���Υȥ���",
335      "  ESC 1 L              ���ɤ��Ƥ��ʤ����롼�פ���",
336      "  /                    ���롼�פ�����ɤǸ����������Ƥ��륰�롼�פ�",
337      "                       ��������Ȥ���'l'��Ȥ���",
338      "  q                    �˥塼���꡼���ν�λ",
339      "  G                    �����������μ���",
340      "  K                    �������⡼�ɤΥȥ���",
341      "  X                    newsrc�ե�����˶���Ū�˽��Ф���",
342      "  ESC-a                ���롼�׵���ɽ����ȥ��롣",
343      "  Ctrl-X Ctrl-T        ���롼�פΰ��֤�����롣",
344      "  m                    ���롼�פ��̤ξ��˰�ư���롣",
345      "  . (�ԥꥪ��)         �Ǹ�Υ����������������֤�",
346      NULL
347 };
348 
349 int Slrn_Japanese_Messages = 0;
350 #endif
351 
352 #define MAX_HELP_LINES 256
353 static char *User_Article_Help[MAX_HELP_LINES];
354 static char *User_Group_Help[MAX_HELP_LINES];
355 
do_help(char ** help)356 static void do_help (char **help)
357 {
358    int i;
359    char **p, *sect = NULL;
360    char quit;
361    char **this_help;
362 #ifdef KANJI
363 #if !defined(SLANG_JVERSION) && !defined(IBMPC_SYSTEM)
364    int charset = Slang_Current_Charset;
365 #endif
366 
367    this_help = p =  Slrn_Japanese_Messages ? Global_Help_J : Global_Help;
368 #else
369    this_help = p = Global_Help;
370 #endif
371 
372    slrn_enable_mouse (0);
373 
374    while (1)
375      {
376 	i = 0;
377 	if (*p == NULL) break;
378 
379 	slrn_push_suspension (0);
380 #ifdef KANJI
381 #if !defined(SLANG_JVERSION) && !defined(IBMPC_SYSTEM)
382 	Slang_Current_Charset = ISO2022JP;
383 #endif
384 #endif
385 
386 	SLsmg_cls ();
387 
388 	if ((sect != NULL) && (**p == ' '))
389 	  {
390 	     SLsmg_set_color (1);
391 	     SLsmg_gotorc (i, 0);
392 	     SLsmg_write_string (sect);
393 	     SLsmg_set_color (0);
394 #ifdef KANJI
395 	     SLsmg_write_string (Slrn_Japanese_Messages
396 				 ? " (³��...)"
397 				 : " (continued)");
398 #else
399 	     SLsmg_write_string (" (continued)");
400 #endif
401 	     i += 2;
402 	  }
403 
404 	while (i < SLtt_Screen_Rows - 4)
405 	  {
406 	     char pp;
407 
408 	     if (*p == NULL)
409 	       {
410 		  if (this_help == help) break;
411 		  this_help = p = help;
412 		  sect = NULL;
413 	       }
414 
415 	     pp = **p;
416 	     if ((pp != ' ') && pp)
417 	       {
418 		  sect = *p;
419 		  if ((i + 6) > SLtt_Screen_Rows) break;
420 		  i++;
421 		  SLsmg_set_color (1);
422 	       }
423 
424 	     SLsmg_gotorc (i, 0);
425 	     SLsmg_write_string (*p); i++;
426 	     if (pp && (pp != ' '))
427 	       {
428 		  SLsmg_set_color (0);
429 		  i++;
430 	       }
431 	     p++;
432 	  }
433 
434 	SLsmg_gotorc (i + 1, 0);
435 	SLsmg_set_color (1);
436 
437 	if ((*p == NULL)
438 #ifdef KANJI
439 	    && (this_help == (Slrn_Japanese_Messages ? Global_Help_J : Global_Help)))
440 #else
441 	    && (this_help == Global_Help))
442 #endif
443 	  {
444 	     this_help = p = help;
445 	     sect = NULL;
446 	  }
447 
448 	if (*p == NULL)
449 	  {
450 #ifdef KANJI
451 	     SLsmg_write_string (Slrn_Japanese_Messages
452 				 ? "\
453 '?'�����ȥإ�פκǽ餫�顣�ۤ��Υ��������ȥ˥塼���꡼���������ޤ�"
454 				 : "\
455 Press '?' to start over, or any other key to return to news reader."
456 #else
457 	     SLsmg_write_string ("\
458 Press '?' to start over, or any other key to return to news reader."
459 #endif
460 				 );
461 	  }
462 #ifdef KANJI
463 	else SLsmg_write_string (Slrn_Japanese_Messages
464 				 ? "\
465 'q'�����ȥإ�פ���ȴ���ޤ����ޤ�'?'�����Ⱥǽ餫�顢¾�Υ�����³����"
466 				 : "\
467 Press 'q' to quit help, '?' to start over, or any other key to continue."
468 #else
469 	else SLsmg_write_string ("\
470 Press 'q' to quit help, '?' to start over, or any other key to continue."
471 #endif
472 				 );
473 
474 	slrn_smg_refresh ();
475 #ifdef KANJI
476 #if !defined(SLANG_JVERSION) && !defined(IBMPC_SYSTEM)
477         Slang_Current_Charset = charset;
478 #endif
479 #endif
480 
481 	slrn_pop_suspension ();
482 
483 	SLang_flush_input ();
484 	quit = SLang_getkey ();
485 	if (quit == '?')
486 	  {
487 #ifdef KANJI
488 	     this_help = p = (Slrn_Japanese_Messages ? Global_Help_J : Global_Help);
489 #else
490 	     this_help = p = Global_Help;
491 #endif
492 	     sect = NULL;
493 	  }
494 	else if ((*p == NULL) || ((quit | 0x20)== 'q'))
495 	    break;
496      }
497    Slrn_Full_Screen_Update = 1;
498    slrn_set_color (0);
499    /* slrn_redraw (); */
500    SLang_flush_input ();
501    slrn_enable_mouse (1);
502 }
503 
slrn_parse_helpfile(char * helpfile)504 int slrn_parse_helpfile (char *helpfile)
505 {
506    FILE *fp;
507    char buf[256];
508    char ch;
509    char **current_help = NULL;
510    int num_lines = 0;
511    unsigned char *b;
512 
513    if (Slrn_Batch)
514      return 0;
515 
516    if (NULL == (fp = fopen (helpfile, "r"))) return -1;
517    while (fgets (buf, sizeof (buf) - 1, fp) != NULL)
518      {
519 	ch = *buf;
520 
521 	/* Skip over common comments */
522 	if ((ch == '#') || (ch == '%') || (ch == ';') || (ch == '!'))
523 	  continue;
524 
525 	b = (unsigned char *) slrn_skip_whitespace (buf);
526 	if (*b == 0) continue;
527 
528 	if (ch == '[')
529 	  {
530 	     /* end current help */
531 	     if (current_help != NULL)
532 	       {
533 		  slrn_free (current_help[num_lines]);
534 		  current_help[num_lines] = NULL;
535 	       }
536 
537 	     num_lines = 0;
538 	     ch = *(buf + 1) | 0x20;
539 	     if (ch == 'a')
540 	       {
541 		  current_help = User_Article_Help;
542 	       }
543 	     else if (ch == 'g') current_help = User_Group_Help;
544 	     else current_help = NULL;
545 
546 	     continue;
547 	  }
548 
549 	if (current_help == NULL) continue;
550 
551 	if (MAX_HELP_LINES == num_lines + 1)
552 	  {
553 	     current_help[num_lines] = NULL;
554 	     current_help = NULL;
555 	     continue;
556 	  }
557 
558 	slrn_free (current_help [num_lines]);
559 
560 	if (NULL != (current_help [num_lines] = (char *) slrn_strmalloc (buf, 0)))
561 	  num_lines++;
562      }
563    if (current_help != NULL)
564      {
565 	slrn_free (current_help[num_lines]);
566 	current_help[num_lines] = NULL;
567      }
568    slrn_fclose (fp);
569    return 0;
570 }
571 
572 
slrn_article_help(void)573 void slrn_article_help (void)
574 {
575    char **h;
576    if (Slrn_Batch) return;
577 #ifdef KANJI
578    if (User_Article_Help[0] != NULL) h = User_Article_Help; else h = Slrn_Japanese_Messages ? Art_Help_J : Art_Help;
579 #else
580    if (User_Article_Help[0] != NULL) h = User_Article_Help; else h = Art_Help;
581 #endif
582    do_help (h);
583 }
584 
slrn_group_help(void)585 void slrn_group_help (void)
586 {
587    char **h;
588    if (Slrn_Batch) return;
589 #ifdef KANJI
590    if (User_Group_Help[0] != NULL) h = User_Group_Help; else h = Slrn_Japanese_Messages ? Group_Help_J : Group_Help;
591 #else
592    if (User_Group_Help[0] != NULL) h = User_Group_Help; else h = Group_Help;
593 #endif
594    do_help (h);
595 }
596