Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
97976d05
Commit
97976d05
authored
May 06, 2012
by
Alejandro Mery
Browse files
fex2bin: finish parsing GPIO data
parent
fd16859d
Changes
1
Show whitespace changes
Inline
Side-by-side
fex2bin.c
View file @
97976d05
...
@@ -126,7 +126,6 @@ static int parse_fex(FILE *in, const char *filename, struct script *script)
...
@@ -126,7 +126,6 @@ static int parse_fex(FILE *in, const char *filename, struct script *script)
(
int
)(
pe
-
p
),
p
);
(
int
)(
pe
-
p
),
p
);
continue
;
continue
;
}
}
perror
(
"malloc"
);
perror
(
"malloc"
);
}
else
if
(
memcmp
(
"port:P"
,
p
,
6
)
==
0
)
{
}
else
if
(
memcmp
(
"port:P"
,
p
,
6
)
==
0
)
{
/* GPIO */
/* GPIO */
...
@@ -136,20 +135,51 @@ static int parse_fex(FILE *in, const char *filename, struct script *script)
...
@@ -136,20 +135,51 @@ static int parse_fex(FILE *in, const char *filename, struct script *script)
else
{
else
{
char
*
end
;
char
*
end
;
int
port
=
*
p
++
-
'A'
;
int
port
=
*
p
++
-
'A'
;
long
port_num
=
strtol
(
p
,
&
end
,
10
);
long
v
=
strtol
(
p
,
&
end
,
10
);
if
(
end
==
p
)
if
(
end
==
p
)
;
goto
invalid_char_at_p
;
else
if
(
port_num
<
0
||
port_num
>
255
)
{
else
if
(
v
<
0
||
v
>
255
)
{
errf
(
"E: %s:%zu: port out of range at %zu.
\n
"
,
errf
(
"E: %s:%zu: port out of range at %zu
(%ld)
.
\n
"
,
filename
,
line
,
p
-
buffer
+
1
);
filename
,
line
,
p
-
buffer
+
1
,
v
);
goto
parse_error
;
goto
parse_error
;
}
else
{
}
else
{
int
data
[]
=
{
-
1
,
-
1
,
-
1
,
-
1
};
int
port_num
=
v
;
p
=
end
;
for
(
int
i
=
0
;
*
p
&&
i
<
4
;
i
++
)
{
if
(
memcmp
(
p
,
"<default>"
,
9
)
==
0
)
{
p
+=
9
;
continue
;
}
else
if
(
*
p
==
'<'
)
{
v
=
strtol
(
++
p
,
&
end
,
10
);
if
(
end
==
p
)
{
;
}
else
if
(
v
<
0
||
v
>
INT32_MAX
)
{
errf
(
"E: %s:%zu: value out of range at %zu (%ld).
\n
"
,
filename
,
line
,
p
-
buffer
+
1
,
v
);
goto
parse_error
;
}
else
if
(
*
end
!=
'>'
)
{
p
=
end
;
p
=
end
;
errf
(
"%s.%s = GPIO %d.%ld (%s)
\n
"
,
}
else
{
p
=
end
+
1
;
data
[
i
]
=
v
;
continue
;
}
}
break
;
}
if
(
*
p
)
goto
invalid_char_at_p
;
if
(
script_gpio_entry_new
(
last_section
,
key
,
port
,
port_num
,
data
))
{
errf
(
"%s.%s = GPIO %d.%d (%d,%d,%d,%d)
\n
"
,
last_section
->
name
,
key
,
last_section
->
name
,
key
,
port
,
port_num
,
p
);
port
,
port_num
,
data
[
0
],
data
[
1
],
data
[
2
],
data
[
3
]);
continue
;
continue
;
}
}
perror
(
"malloc"
);
}
}
}
}
else
if
(
isdigit
(
*
p
))
{
}
else
if
(
isdigit
(
*
p
))
{
long
long
v
=
0
;
long
long
v
=
0
;
...
@@ -157,17 +187,17 @@ static int parse_fex(FILE *in, const char *filename, struct script *script)
...
@@ -157,17 +187,17 @@ static int parse_fex(FILE *in, const char *filename, struct script *script)
v
=
strtoll
(
p
,
&
end
,
0
);
v
=
strtoll
(
p
,
&
end
,
0
);
p
=
end
;
p
=
end
;
if
(
p
!=
pe
)
{
if
(
p
!=
pe
)
{
;
goto
invalid_char_at_p
;
}
else
if
(
v
>
UINT32_MAX
)
{
}
else
if
(
v
>
UINT32_MAX
)
{
errf
(
"E: %s:%zu: value out of range %lld.
\n
"
,
errf
(
"E: %s:%zu: value out of range %lld.
\n
"
,
filename
,
line
,
v
);
filename
,
line
,
v
);
goto
parse_error
;
}
else
if
(
script_single_entry_new
(
last_section
,
key
,
v
))
{
}
else
if
(
script_single_entry_new
(
last_section
,
key
,
v
))
{
errf
(
"%s.%s = %lld
\n
"
,
errf
(
"%s.%s = %lld
\n
"
,
last_section
->
name
,
key
,
v
);
last_section
->
name
,
key
,
v
);
continue
;
continue
;
}
}
}
}
goto
parse_error
;
invalid_char_at_p:
invalid_char_at_p:
errf
(
"E: %s:%zu: invalid character at %zu.
\n
"
,
errf
(
"E: %s:%zu: invalid character at %zu.
\n
"
,
filename
,
line
,
p
-
buffer
+
1
);
filename
,
line
,
p
-
buffer
+
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment