Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 *
3
 *
4
 *
5
 */
6
#include <ll/i386/cons.h>
7
#include <drivers/keyb.h>
8
 
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include <string.h>
12
 
13
int main(int argc,char *argv[])
14
{
15
  char buffer[256];
16
  FILE *fin;
17
  char *s;
18
  int res;
19
  int c,n;
20
  char ch;
21
 
22
  /*
23
  temp_device=bdev_scan_devices(choose_temp_callback);
24
  if (temp_device<0) {
25
    cprintf("can't find a filesystem to mount on /TEMP!!!\n");
26
    return -1;
27
  }
28
 
29
  res=mount(temp_device,FS_MSDOS,"/TEMP",NULL);
30
  if (res!=0) {
31
    cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
32
    sys_end();
33
    return -1;
34
  }
35
  */
36
 
37
  /*
38
   *
39
   */
40
 
41
  cprintf("opening...\n");
42
  fin=fopen("/TEMP/ALFA2.TXT","r");
43
  cprintf("opened!\n");
44
 
45
  if (fin!=NULL) {
46
 
47
    n=-1;
48
    cprintf("fscanf()ing...\n");
49
    res=fscanf(fin,"number %i",&n);
50
    cprintf("fscanf()ed...\n");
51
    if (res!=1) {
52
      cprintf("error on 1st fscanf() res=%i\n",res);
53
      return 0;
54
    }
55
    cprintf("scanned number %i (exact 103)\n",n);
56
 
57
    s=fgets(buffer,sizeof(buffer),fin);
58
    if (s==NULL) {
59
      cprintf("error on 1st fgets()\n");
60
      return 0;
61
    }
62
    s=fgets(buffer,sizeof(buffer),fin);
63
    if (s==NULL) {
64
      cprintf("error on 2nd fgets()\n");
65
      return 0;
66
    }
67
    s=fgets(buffer,sizeof(buffer),fin);
68
    if (s==NULL) {
69
      cprintf("error on 3rd fgets()\n");
70
      return 0;
71
    }
72
 
73
    cprintf("fscanf()ing...\n");
74
    res=fscanf(fin,"line %i error letter '%c'",&n,&ch);
75
    cprintf("fscanf()ed...\n");
76
    if (res!=2) {
77
      cprintf("error on 2nd fscanf() res=%i\n",res);
78
      return 0;
79
    }
80
    cprintf("scanned number %i (exact 205) characer '%c' (exact 'c')\n",n,ch);
81
 
82
    cprintf("closing...\n");
83
    fclose(fin);
84
    cprintf("closed!\n");
85
  }
86
 
87
  cprintf("[press 'x' to exit]\n");
88
  while ((c = keyb_getchar()) != 'x') ;
89
 
90
  return 0;
91
}