Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 *
3
 *
4
 *
5
 */
6
 
7
#include <ll/i386/cons.h>
8
#include <drivers/keyb.h>
9
 
10
#include <stdio.h>
11
#include <string.h>
12
 
13
int main(int argc,char *argv[])
14
{
15
  char buffer[256];
16
  FILE *fin;
17
  int res;
18
  int c;
19
  int flag=1;
20
 
21
  /* prova di rewind() */
22
 
23
  cprintf("opening...\n");
24
  fin=fopen("/TEMP/ALFA1.TXT","r");
25
  cprintf("opened!\n");
26
 
27
  cprintf("res=%p\n",fin);
28
 
29
  if (fin!=NULL) {
30
 
31
  REDO:
32
 
33
    while (!feof(fin)) {
34
      cprintf("reading...\n");
35
      res=fread(buffer,1,sizeof(buffer)-2,fin);
36
      cprintf("read!\n");
37
 
38
      cprintf("res=%i\n",res);
39
      buffer[res<sizeof(buffer)-1?res:sizeof(buffer)-1]='\0';
40
      cprintf("'%s'\n",buffer);
41
    }
42
 
43
    if (flag) {
44
      flag=0;
45
      cprintf("rewinding...\n");
46
      rewind(fin);
47
      cprintf("rewinded!\n");
48
      goto REDO;
49
    }
50
 
51
    cprintf("closing...\n");
52
    fclose(fin);
53
    cprintf("closed!\n");
54
  }
55
 
56
  cprintf("[press 'x' to exit]\n");
57
  while ((c = keyb_getch(BLOCK)) != 'x') ;
58
 
59
  return 0;
60
}