progress
This commit is contained in:
		
							parent
							
								
									48dcb7155e
								
							
						
					
					
						commit
						287fed9795
					
				
							
								
								
									
										33
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								src/main.c
									
									
									
									
									
								
							@ -68,21 +68,27 @@ int checkparams(int *argc, char *argv[]) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct access_log_entry_t parseLogline(char *accessLogLine) {
 | 
					struct access_log_entry_t parseLogline(char *accessLogLine) {
 | 
				
			||||||
    struct access_log_entry_t logEntry;
 | 
					    struct access_log_entry_t logEntry;
 | 
				
			||||||
    logEntry.remote_addr = parse_remote_address(accessLogLine);
 | 
					    //logEntry.remote_addr = parse_remote_address(accessLogLine);
 | 
				
			||||||
    return logEntry;
 | 
					    return logEntry;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char parse_remote_address(char *accessLogLine) {
 | 
					//char* parse_remote_address(char *accessLogLine) {
 | 
				
			||||||
    char *remote_adress[18];
 | 
					//    return 1;
 | 
				
			||||||
    regcomp
 | 
					//}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t my_strlen(char *s) {
 | 
					unsigned int count_lines(FILE *filepointer) {
 | 
				
			||||||
    uint32_t counter = 0;
 | 
					    rewind(filepointer);
 | 
				
			||||||
    while (s[counter] != '\0') {
 | 
					    unsigned int lines = 0;
 | 
				
			||||||
        counter++;
 | 
					    char c;
 | 
				
			||||||
 | 
					    for(c=getc(filepointer); c != EOF; c = getc(filepointer)) {
 | 
				
			||||||
 | 
					        if(c=='\n'){
 | 
				
			||||||
 | 
					            lines += 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return counter;
 | 
					    char msg[BUF];
 | 
				
			||||||
 | 
					    sprintf(msg, "Detected %d Lines in filestream\n", lines);
 | 
				
			||||||
 | 
					    debugmsg(msg);
 | 
				
			||||||
 | 
					    return lines;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(int argc, char *argv[]) {
 | 
					int main(int argc, char *argv[]) {
 | 
				
			||||||
@ -107,6 +113,7 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
        int filesize = ftell(fp);
 | 
					        int filesize = ftell(fp);
 | 
				
			||||||
        sprintf(msg, "Datei %s geöffnet. Speicheradresse %p, Speichergröße %d Byte\n", filepath, &fp, filesize);
 | 
					        sprintf(msg, "Datei %s geöffnet. Speicheradresse %p, Speichergröße %d Byte\n", filepath, &fp, filesize);
 | 
				
			||||||
        debugmsg(msg);
 | 
					        debugmsg(msg);
 | 
				
			||||||
 | 
					        count_lines(fp);
 | 
				
			||||||
        char *access_log_buffer = malloc(BUF);
 | 
					        char *access_log_buffer = malloc(BUF);
 | 
				
			||||||
        struct access_log_entry_t *access_log_table = malloc(sizeof(struct access_log_entry_t)*BUF);
 | 
					        struct access_log_entry_t *access_log_table = malloc(sizeof(struct access_log_entry_t)*BUF);
 | 
				
			||||||
        if(access_log_buffer==NULL){
 | 
					        if(access_log_buffer==NULL){
 | 
				
			||||||
@ -114,12 +121,6 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
            return -1;
 | 
					            return -1;
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
        rewind(fp);
 | 
					        rewind(fp);
 | 
				
			||||||
        //while (fgets(access_log_buffer, filesize, fp)){
 | 
					 | 
				
			||||||
        //    debugmsg("entered loop\n");
 | 
					 | 
				
			||||||
        //    sprintf(outputline, "LINE %d: %s", counter+1, access_log_buffer);
 | 
					 | 
				
			||||||
        //    fputs(outputline, stdout);
 | 
					 | 
				
			||||||
        //    debugmsg("endloop");
 | 
					 | 
				
			||||||
        //}
 | 
					 | 
				
			||||||
        for (int counter = 0; counter < 10 && fgets(access_log_buffer, filesize, fp); counter++) {
 | 
					        for (int counter = 0; counter < 10 && fgets(access_log_buffer, filesize, fp); counter++) {
 | 
				
			||||||
            //debugmsg("entered loop");
 | 
					            //debugmsg("entered loop");
 | 
				
			||||||
            char outputline[BUF];
 | 
					            char outputline[BUF];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user