Waitrud Weber’s blog

things and reminders for memories

CodeAnalyzer: html: The way we are.

fp doesn't increase in the function get_inside but we can believe that it works well.

And fp can be used in the main function read_html_tag next.

1 main.cpp  Thu Apr 07 21:10:20 2022 -
2

 64 :int read_html_tag(char* filename ) {
 65 :    STRUCT_FILE structure_fp;
 66 :    int file_end;
 67 :    FILE* fp;
 68 :    char* p_dummy;
 69 :    int i;
 70 :    int result;
 71 :    char key_buffer[255];
 72 :
 73 :    printf("int read_html_tag(char* filename ) starts.\r\n");
 74 :
 75 :    fp = fopen(filename, "rb");
 76 :    printf("1 fp|%d|\r\n", fp);
 77 :    structure_fp.file_start = fp;
 78 :    structure_fp.fp = fp;
 79 :
 80 :    file_end = filesize(fp);
 81 :    structure_fp.file_end_index = file_end;
 82 :
 83 :    printf("file_size:%d\r\n", file_end);
 84 :    printf("2 fp|%d|\r\n", fp);
 85 :
 86 :    for ( i =0; i<file_end; i++ ) {
 87 :        structure_fp.index = i;
 88 :        p_dummy = get_string( structure_fp , 5);
 89 :        p_dummy[5] = '\0';
 90 :        if ( m_start_with ( (char*)p_dummy, "<" ) == 1 ) {
 91 :            printf("We found the |<| index %d fp|%d|.\r\n", i, fp );
 92 :            result = get_inside( key_buffer, 255, ">", &structure_fp );
 93 :            printf("key_buffer |%s|\r\n", key_buffer );
 94 :            exit(-1);
 95 :        }
 96 :    }
 97 :
 98 :    printf("int read_html_tag(char* filename ) ends.\r\n");
 99 :    return 0;
100 :}
101 :
102 :int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) {
103 :    int index;
104 :    char* p_dummy;
105 :    printf("int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) starts.\r\n");
106 :
107 :    for(int i=0; i<max_buffer; i++ ) {
108 :        sfp->index++;
109 :        p_dummy = get_string( *sfp , 5);
110 :        if ( m_start_with ( (char*)p_dummy, ">" ) == 1 ) {
111 :            key_buffer[i] ='\0';
112 :            printf("We found the |>| index %d fp|%d|.\r\n", sfp->index, sfp->fp );
113 :            printf("key_buffer |%s|\r\n", key_buffer );
114 :            printf("int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) returns 1.\r\n");
115 :            return 1;
116 :        }
117 :        key_buffer[i] = p_dummy[0];
118 :    }
119 :
120 :    printf("int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) ends.\r\n");
121 :    return 0;
122 :}

 
3 > .\winmain_001.exe
int read_html_tag(char* filename ) starts.
1 fp|1986960488|
file_size:1084
2 fp|1986960488|
We found the |<| index 0 fp|1986960488|.
int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) starts.
We found the |>| index 2 fp|1986960488|.
key_buffer |p|
int get_inside( char* key_buffer, int max_buffer, char* end_string, STRUCT_FILE* sfp ) returns 1.
key_buffer |p|