2 static char copyright[] = "Copyright 1992 The University of Adelaide";
8 * Author: Mark R. Prior
9 * Communications and Systems Branch
10 * Information Technology Division
11 * The University of Adelaide
12 * E-mail: mrp@itd.adelaide.edu.au
18 * Redistribution and use in source and binary forms are permitted
19 * provided that the above copyright notice and this paragraph are
20 * duplicated in all such forms and that any documentation,
21 * advertising materials, and other materials related to such
22 * distribution and use acknowledge that the software was developed
23 * by the University of Adelaide. The name of the University may not
24 * be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
28 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
34 needHelp( char *reason )
36 char filename[MAXPATHLEN];
43 if ( reason == NULL || *reason == '\0' ) {
44 sprintf( filename, "%s/%s/general", helpDir, language );
45 if ( ( help = fopen( filename, "r" ) ) == NULL ) {
46 printFormatted( lineLength, TRUE, stdout,
47 "Sorry cannot open general information help file" );
51 sprintf( filename, "%s/%s/%s", helpDir, language,
52 lowerCase( reason ) );
53 if ( ( help = fopen( filename, "r" ) ) == NULL ) {
54 sprintf( filename, "%s/%s/%s", helpDir, defaultLanguage,
55 lowerCase( reason ) );
56 if ( ( help = fopen( filename, "r" ) ) == NULL ) {
57 printFormatted( lineLength, TRUE, stdout,
58 "Sorry cannot open help file for topic \"%s\"",
62 printFormatted( lineLength, TRUE, stdout,
63 "Sorry no help in %s, using default language (%s).",
64 language, defaultLanguage );
68 while ( fgets( buffer, BUFSIZ, help ) != NULL ) {
70 while ( i-- > 0 && ( buffer[i] == '\n' || buffer[i] == '\r' ) )
72 printFormatted( lineLength, FALSE, stdout, "%s", buffer );
75 if ( reason == NULL || *reason == '\0' ) {
76 sprintf( filename, "%s/%s", helpDir, language );
77 if ( ( dir = opendir( filename ) ) == NULL )
79 printFormatted( lineLength, FALSE, stdout, "" );
80 printFormatted( lineLength, FALSE, stdout,
81 "Further information is available on the following topics" );
82 for ( entry = readdir( dir ); entry != NULL; entry = readdir( dir ) )
83 if ( !EQ(entry->d_name, "." ) && !EQ(entry->d_name, ".." ) )
84 printFormatted( lineLength, FALSE, stdout,
85 " %s", lowerCase( entry->d_name ) );