ramstart.c
1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#ifndef MSDOS /* { */
# include <sys/types.h>
# include <unistd.h>
#endif
/*
* Types
*/
/*
* Definitions
*/
/*
* Globals
*/
char *command_name;
long diskType;
void usage(void)
{
fprintf(stderr, "Usage: ramstart type\n");
return;
} /* usage() */
int ramStartLba[] =
{
1418, 1966, 2514, 3062, 3610, 4088, 4292
};
int main(int argc, char **argv)
{
char *p;
#ifdef MSDOS
command_name = (char *)cut_dir_fname(argv[0]);
#else
if ((command_name = rindex(argv[0], '/')) != NULL)
command_name++;
else
command_name = argv[0];
#endif
/*
* Parse arguments
*/
while( --argc > 0 )
{
if ( **(++argv) == '-' )
{
usage();
exit(1);
} /* if ( **(++argv) == '-' ) */
else
break;
} /* while( argc > 0 ) */
if (argc == 1)
{
diskType = strtol( *argv, (char **)NULL, 0);
}
else
{
usage();
exit(1);
}
/*
* ディスクタイプが合法的なものかチェック
*/
if ( (diskType < 0) || (diskType > 6) )
{
fprintf(stderr, "%s: type is illegal. It must be in [0-6].\n",
command_name);
exit(1);
}
/*
* ram start を表示(タイプ6 には ram 領域はない)
*/
if (diskType == 6)
{
fprintf(stdout, "Disk type 6 does not have ram area.\n");
}
else
fprintf(stdout, "%d\n", ramStartLba[diskType]);
exit(0);
/* NOTREACHED */
} /* main() */