Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1200 giacomo 1
#include <kernel/kern.h>
2
#include <stdlib.h>
3
#include "parser.h"
4
 
5
int dos_preload(char *file_name, long max_size, void **start, void **end)
6
{
7
  DOS_FILE* file;
8
  void      *buf;
9
  long      rd;
10
 
11
 
12
  file = DOS_fopen(file_name,"r");
13
  if (file == NULL) return -1;
14
 
15
  buf = malloc(max_size);
16
  *start = buf;
17
 
18
  while(((rd = DOS_fread(buf, sizeof(BYTE), 2048, file)) == 2048) &&
19
        ((buf - *start + rd) < (max_size-2048))) {
20
        buf += rd;
21
  }
22
 
23
  *end = buf + rd;
24
 
25
  DOS_fclose(file);
26
  return(0);
27
 
28
}
29
 
30
int line_reader(void *start, void *end, struct timespec *total, struct loader_task *start_loader_task)
31
{
32
 
33
  char line_buf[1000];
34
  char *pbuf = start;
35
  int i,res,line_num,total_loader_task;
36
 
37
  NULL_TIMESPEC(total);
38
 
39
  line_num = 0;
40
  total_loader_task = 0;
41
  while ((void *)(pbuf) < end) {
42
    i = 0;
43
    line_num++;
44
    while ((char)(pbuf[i]) != '\n') {
45
      line_buf[i] = pbuf[i];
46
      i++;
47
    }
48
    pbuf += i+1;
49
    line_buf[i] = 0;
50
    res = line_parser(line_buf, line_num, total, start_loader_task);
51
    if (res == 2) {
52
      total_loader_task++;
53
      start_loader_task = start_loader_task->next;
54
    }
55
  }
56
 
57
  cprintf("Total decoded lines %d\n",line_num);
58
  cprintf("Total loader task %d\n",total_loader_task);
59
  cprintf("Simulation time sec = %ld usec = %ld\n",total->tv_sec,total->tv_nsec/1000);
60
 
61
  return 0;
62
 
63
}