- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
for (i = 1; i < argc; i++) {
p = argv[i];
if ((*p != '-') && (*p != '/'))
{
printf("Unknown option %s\n", p);
return 1;
}
p++;
if (strncmp(p, "pcir=", 5) == 0)
{
sscanf(p+5, "%lli", &pci_raddr);
opt |= 1;
}
if (strncmp(p, "pciw=", 5) == 0)
{
sscanf(p+5, "%lli", &pci_waddr);
opt |= 2;
}
if (strncmp(p, "rwlen=", 6) == 0)
sscanf(p+6, "%i", &rwlen);
if (strncmp(p, "count=", 6) == 0)
sscanf(p+6, "%i", &count);
if (strncmp(p, "ch=", 3) == 0)
channel = p+3;
if (strncmp(p, "poll", 4) == 0)
poll = 1;
if (strncmp(p, "fpga_read=", 10) == 0)
{
sscanf(p+10, "%i", &offset);
fpga_read_flag = 1;
}
if (strncmp(p, "fpga_write=", 11) == 0)
{
sscanf(p+11, "%i", &offset);
fpga_write_flag = 1;
}
if (strncmp(p, "data=", 5) == 0)
{
sscanf(p+5, "%i", &data);
data_valid = 1;
}
if (strncmp(p, "dump_to_file=", 13) == 0)
{
filename = p+13;
dump_to_file = 1;
}
if (strncmp(p, "loadnios", 8) == 0)
{
filename = p+8;
load_nios = 1;
}
if (strncmp(p, "DUMP", 4) == 0) // -DUMP
dump = 1;
if (strncmp(p, "flash_read", 10) == 0) // -flash_read
{
flash_read_flag = 1;
}
if (strncmp(p, "file_to_flash", 13) == 0) // -file_to_flash
file_to_flash = 1;
if (strncmp(p, "file=", 5) == 0) // -file
{
fname = p+5;
}
if (strncmp(p, "base=", 5) == 0) // -base
{
sscanf(p+5, "%i", &base);
basevalid = 1;
}
if (strncmp(p, "card=", 5) == 0) // -crd
sscanf(p+5, "%i", &card);
if (strncmp(p, "ver", 3) == 0)
ver = 1;
if (strncmp(p, "dev=", 4) == 0) // -deм
dev = p+4;
}
"А я напишу свой собственный комманд лайн парсер, с хуитой и говном"
Комментарии (0) RSS
Добавить комментарий