[2759] | 1 | #include <stdio.h> |
---|
| 2 | #include <stdlib.h> |
---|
| 3 | #include <string.h> |
---|
| 4 | #define COMPARE(A,B) ( ! strncmp ( A , B , strlen( B ) ) ) |
---|
| 5 | #define COMPARE2(A,B) ( ! strcmp ( A , B ) ) |
---|
| 6 | #define INLINELEN (4*8192) |
---|
| 7 | #define VARLEN 128 |
---|
| 8 | #define MAXARGS (4*8192) |
---|
| 9 | #define MAXDEPTH 50 |
---|
| 10 | |
---|
| 11 | #define DIR "tools/code_dbase" |
---|
| 12 | |
---|
| 13 | char levels[MAXDEPTH][VARLEN] ; |
---|
| 14 | |
---|
| 15 | main( int argc, char *argv[] ) |
---|
| 16 | { |
---|
| 17 | int indent ; |
---|
| 18 | int i ; |
---|
| 19 | char *rout ; |
---|
| 20 | indent = atoi( argv[1] ) ; |
---|
| 21 | rout = argv[2] ; |
---|
| 22 | for ( i = 0 ; i < MAXDEPTH ; i++ ) strcpy( levels[i] , "" ) ; |
---|
| 23 | subinfo_calls ( rout, indent ) ; |
---|
| 24 | |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | subinfo_calls ( char *rout, int indent ) |
---|
| 28 | { |
---|
| 29 | FILE *CALLERS ; |
---|
| 30 | FILE *CALLER ; |
---|
| 31 | char inln[INLINELEN], inln2[INLINELEN] ; |
---|
| 32 | int i ; |
---|
| 33 | char fname[VARLEN], fname2[VARLEN], sf[VARLEN] ; |
---|
| 34 | char u0[VARLEN] , u1[VARLEN] , u2[VARLEN] ; |
---|
| 35 | char v0[VARLEN] , v1[VARLEN] , v2[VARLEN] ; |
---|
| 36 | char u0_upper[VARLEN] ; |
---|
| 37 | |
---|
| 38 | if ( COMPARE( rout, "add_msg_" ) || |
---|
| 39 | COMPARE( rout, "wrf_error" ) || |
---|
| 40 | COMPARE( rout, "wrf_debug" ) || |
---|
| 41 | COMPARE( rout, "wrf_message" ) || |
---|
| 42 | COMPARE( rout, "stencil_" ) || |
---|
| 43 | COMPARE( rout, "start_timing" ) || |
---|
| 44 | COMPARE( rout, "end_timing" ) ) exit(0) ; |
---|
| 45 | |
---|
| 46 | sprintf(fname, "%s/calls", DIR ) ; |
---|
| 47 | if (( CALLERS = fopen( fname, "r" )) == NULL ) { fprintf(stderr,"subinfo_calls: cannot open %s\n",fname) ; exit(1) ; } |
---|
| 48 | |
---|
| 49 | while ( fgets( inln, INLINELEN, CALLERS ) != NULL ) { |
---|
| 50 | get_token_n ( inln, " ", 0, u0 ) ; remove_nl(u0) ; |
---|
| 51 | get_token_n ( inln, " ", 1, u1 ) ; remove_nl(u1) ; |
---|
| 52 | get_token_n ( inln, " ", 2, u2 ) ; remove_nl(u2) ; |
---|
| 53 | if ( COMPARE2( rout, u2 ) && ! COMPARE( u2 , u0 ) ) { |
---|
| 54 | sprintf( fname2 , "%s/%s", DIR, u0 ) ; |
---|
| 55 | if (( CALLER = fopen( fname2, "r" )) == NULL ) { fprintf(stderr,"subinfo_calls: cannot open %s\n",fname2 ) ; exit(2) ; } |
---|
| 56 | while ( fgets( inln2 , INLINELEN, CALLER ) != NULL ) { |
---|
| 57 | get_token_n ( inln2, " ", 0, v0 ) ; remove_nl ( v0 ) ; |
---|
| 58 | get_token_n ( inln2, " ", 1, v1 ) ; remove_nl ( v1 ) ; |
---|
| 59 | if ( COMPARE2( v0, "sourcefile" ) ) { strcpy ( sf , v1 ) ; break ; } |
---|
| 60 | } |
---|
| 61 | fclose(CALLER) ; |
---|
| 62 | for ( i = 0 ; i < indent * 3 ; i++ ) { |
---|
| 63 | printf( "  " ) ; |
---|
| 64 | } |
---|
| 65 | switch_little_big_f( sf ) ; |
---|
| 66 | #if 0 |
---|
| 67 | printf("<a href=\"%s.html\">%s</a> (<a href=\"../../%s\">%s</a>)<br>\n", u0, u0, sf, sf ) ; |
---|
| 68 | #else |
---|
| 69 | strcpy( u0_upper, u0 ) ; upper_case_str( u0_upper ) ; |
---|
| 70 | printf("<a href=\"%s.html\">%s</a> (<a href=\"../../../wrfbrowser/html_code/%s.html#%s\">%s</a>)<br>\n", u0, u0, sf, u0_upper,sf ) ; |
---|
| 71 | #endif |
---|
| 72 | /* RECURSION */ |
---|
| 73 | if ( ! COMPARE2( u0 , levels[ indent+1 ] ) ) { |
---|
| 74 | strcpy( levels[ indent+1 ], u0 ) ; |
---|
| 75 | subinfo_calls ( u0 , indent + 1 ) ; |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | fclose( CALLERS ) ; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|