00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "stdio.h"
00028 #include "string.h"
00029 #include "stdlib.h"
00030 #include <sys/stat.h>
00031 #include "errno.h"
00032
00033 int
00034 main()
00035 {
00036 char *p1, *p2;
00037 char doc[150][1024], b[1024], tok[80];
00038 int item = 0, j;
00039 FILE *fp, *fp1;
00040 struct stat buf;
00041
00042 if ( ( fp = fopen( "plplot_octave_txt/plplot.doc", "r" ) ) == NULL )
00043 {
00044 perror( "plplot.doc not found:" );
00045 exit( 1 );
00046 }
00047
00048 while ( !feof( fp ) && fgets( b, sizeof ( b ), fp ) != NULL )
00049 {
00050 if ( strchr( b, '-' ) )
00051 strcpy( doc[item++], b );
00052 }
00053 fclose( fp );
00054
00055 if ( ( fp = fopen( "tmp_stub", "r" ) ) == NULL )
00056 {
00057 perror( "tmp_stub not found:" );
00058 exit( 1 );
00059 }
00060
00061 while ( !feof( fp ) && fgets( b, sizeof ( b ), fp ) != NULL )
00062 {
00063 if ( ( p2 = strchr( b, '(' ) ) )
00064 {
00065 p1 = p2;
00066 while ( *p1-- != ' ' )
00067 ;
00068 p1 += 2;
00069 if ( *( p1 + 1 ) == '_' )
00070 p1 += 2;
00071 strncpy( tok, p1, p2 - p1 );
00072 *( tok + (int) ( p2 - p1 ) ) = '\0';
00073 printf( "%s", b );
00074 if ( fgets( b, sizeof ( b ), fp ) == NULL )
00075 {
00076 fprintf( stderr, "Error reading line\n" );
00077 return 1;
00078 }
00079 printf( "%s%%\n", b );
00080
00081 sprintf( b, "plplot_octave_txt/%s.txt", tok );
00082 if ( stat( b, &buf ) && errno == ENOENT )
00083 {
00084 fprintf( stderr, "%s not found, trying plplot.doc... ", b );
00085 strcat( tok, "\t" );
00086 for ( j = 0; j < item; j++ )
00087 {
00088 if ( strncmp( doc[j], tok, strlen( tok ) ) == 0 )
00089 {
00090 printf( "%% %s", &doc[j][strlen( tok ) + 4] );
00091 break;
00092 }
00093 }
00094 if ( j == item )
00095 {
00096 fprintf( stderr, "%s not found\n", tok );
00097 printf( "%% No online help available. Help me, write and submit the documentation, or at least write a one line descriptive text.\n" );
00098 }
00099 else
00100 fprintf( stderr, "%s OK\n", tok );
00101 }
00102 else
00103 {
00104 printf( "%% Original PLplot call documentation:\n%%\n" );
00105 fp1 = fopen( b, "r" );
00106 while ( !feof( fp1 ) && fgets( b, sizeof ( b ), fp1 ) != NULL )
00107 {
00108 printf( "%% %s", b );
00109 }
00110 fclose( fp1 );
00111 }
00112 if ( fgets( b, sizeof ( b ), fp ) == NULL )
00113 {
00114 fprintf( stderr, "Error reading line\n" );
00115 return 1;
00116 }
00117 if ( fgets( b, sizeof ( b ), fp ) == NULL )
00118 {
00119 fprintf( stderr, "Error reading line\n" );
00120 return 1;
00121 }
00122 printf( "%s", b );
00123 if ( fgets( b, sizeof ( b ), fp ) == NULL )
00124 {
00125 fprintf( stderr, "Error reading line\n" );
00126 return 1;
00127 }
00128 printf( "%s\n", b );
00129 }
00130 }
00131 fclose( fp );
00132 exit( 0 );
00133 }