Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
LabComm
Commits
4143e65f
Commit
4143e65f
authored
12 years ago
by
Sven Robertz
Browse files
Options
Downloads
Patches
Plain Diff
array skipping maybe works
parent
a733b92f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/c/experimental/labcomm_sig_parser.c
+17
-12
17 additions, 12 deletions
lib/c/experimental/labcomm_sig_parser.c
with
17 additions
and
12 deletions
lib/c/experimental/labcomm_sig_parser.c
+
17
−
12
View file @
4143e65f
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#undef DEBUG_STACK
#undef DEBUG_STACK
#undef DEBUG_READ
#undef DEBUG_READ
#def
ine
EXIT_WHEN_RECEIVING_DATA //arrays (at least varsize not working)
#
un
def EXIT_WHEN_RECEIVING_DATA //arrays (at least varsize not working)
#define FALSE 0
#define FALSE 0
#define TRUE 1
#define TRUE 1
...
@@ -437,7 +437,7 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
...
@@ -437,7 +437,7 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
unsigned
int
skip
=
0
;
unsigned
int
skip
=
0
;
unsigned
int
tot_nbr_elem_tmp
=
1
;
unsigned
int
tot_nbr_elem_tmp
=
1
;
unsigned
int
nIdx
=
unpack32
(
sig
,
*
pos
);
unsigned
int
nIdx
=
unpack32
(
sig
,
*
pos
);
printf
(
"skip_array: nIdx = %d
\n
"
,
nIdx
);
printf
(
"skip_array: nIdx = %d
(from sig)
\n
"
,
nIdx
);
*
pos
+=
4
;
*
pos
+=
4
;
unsigned
int
idx
[
nIdx
];
unsigned
int
idx
[
nIdx
];
unsigned
int
nVar
=
0
;
unsigned
int
nVar
=
0
;
...
@@ -447,7 +447,7 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
...
@@ -447,7 +447,7 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
for
(
i
=
0
;
i
<
nIdx
;
i
++
)
{
for
(
i
=
0
;
i
<
nIdx
;
i
++
)
{
idx
[
i
]
=
unpack32
(
sig
,
*
pos
);
idx
[
i
]
=
unpack32
(
sig
,
*
pos
);
*
pos
+=
4
;
*
pos
+=
4
;
printf
(
"skip_array: idx[%d]=%d
\n
"
,
i
,
idx
[
i
]);
printf
(
"skip_array: idx[%d]=%d
(from sig)
\n
"
,
i
,
idx
[
i
]);
if
(
idx
[
i
]
==
0
)
{
if
(
idx
[
i
]
==
0
)
{
nVar
++
;
nVar
++
;
}
else
{
}
else
{
...
@@ -458,7 +458,8 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
...
@@ -458,7 +458,8 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
for
(
i
=
0
;
i
<
nVar
;
i
++
)
{
for
(
i
=
0
;
i
<
nVar
;
i
++
)
{
var
[
i
]
=
get32
(
d
);
var
[
i
]
=
get32
(
d
);
printf
(
"skip_array: var[%d]=%d
\n
"
,
i
,
var
[
i
]);
printf
(
"skip_array: var[%d]=%d (from sample)
\n
"
,
i
,
var
[
i
]);
tot_nbr_elem_tmp
*=
var
[
i
];
}
}
unsigned
int
type
=
unpack32
(
sig
,
*
pos
);
unsigned
int
type
=
unpack32
(
sig
,
*
pos
);
...
@@ -468,13 +469,11 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
...
@@ -468,13 +469,11 @@ int skip_array(buffer *d, unsigned char *sig, unsigned int len, unsigned int *po
skip
=
elemSize
*
tot_nbr_elem_tmp
;
skip
=
elemSize
*
tot_nbr_elem_tmp
;
printf
(
"skip_array: skip: %d * %d = %d
\n
"
,
elemSize
,
tot_nbr_elem_tmp
,
skip
);
printf
(
"skip_array: skip: %d * %d = %d
\n
"
,
tot_nbr_elem_tmp
,
elemSize
,
skip
);
advancen
(
d
,
skip
);
advancen
(
d
,
skip
);
skip
+=
nVar
;
return
skip
+
4
*
nVar
;
return
skip
;
}
}
int
skip_struct
(
buffer
*
d
,
unsigned
char
*
sig
,
unsigned
int
len
,
unsigned
int
*
pos
)
{
int
skip_struct
(
buffer
*
d
,
unsigned
char
*
sig
,
unsigned
int
len
,
unsigned
int
*
pos
)
{
...
@@ -486,14 +485,19 @@ int skip_struct(buffer *d, unsigned char *sig, unsigned int len, unsigned int *p
...
@@ -486,14 +485,19 @@ int skip_struct(buffer *d, unsigned char *sig, unsigned int len, unsigned int *p
for
(
i
=
0
;
i
<
nFields
;
i
++
)
{
for
(
i
=
0
;
i
<
nFields
;
i
++
)
{
//skip name
//skip name
unsigned
int
namelen
=
unpack32
(
sig
,
*
pos
);
unsigned
int
namelen
=
unpack32
(
sig
,
*
pos
);
*
pos
+=
(
4
+
namelen
);
// 32bit len + actual string
#ifdef DEBUG
#ifdef DEBUG
printf
(
"namelen==%d
\n
"
,
namelen
);
printf
(
"namelen==%d"
,
namelen
);
char
name
[
namelen
+
1
];
name
[
namelen
]
=
0
;
strncpy
(
name
,
sig
+*
pos
+
4
,
namelen
);
printf
(
", name = %s"
,
name
);
#endif
#endif
*
pos
+=
(
4
+
namelen
);
// 32bit len + actual string
unsigned
int
type
=
unpack32
(
sig
,
*
pos
);
unsigned
int
type
=
unpack32
(
sig
,
*
pos
);
*
pos
+=
4
;
*
pos
+=
4
;
#ifdef DEBUG
#ifdef DEBUG
printf
(
"type == %x
\n
"
,
type
);
printf
(
"
:
type == %x
\n
"
,
type
);
#endif
#endif
skipped
+=
skip_type
(
type
,
d
,
sig
,
len
,
pos
);
skipped
+=
skip_type
(
type
,
d
,
sig
,
len
,
pos
);
}
}
...
@@ -548,6 +552,7 @@ int skip_type(unsigned int type, buffer *d,
...
@@ -548,6 +552,7 @@ int skip_type(unsigned int type, buffer *d,
case
ARRAY_DECL
:
case
ARRAY_DECL
:
printf
(
"array
\n
"
);
printf
(
"array
\n
"
);
skipped
+=
skip_array
(
d
,
sig
,
len
,
pos
);
skipped
+=
skip_array
(
d
,
sig
,
len
,
pos
);
break
;
case
STRUCT_DECL
:
case
STRUCT_DECL
:
printf
(
"struct
\n
"
);
printf
(
"struct
\n
"
);
skipped
+=
skip_struct
(
d
,
sig
,
len
,
pos
);
skipped
+=
skip_struct
(
d
,
sig
,
len
,
pos
);
...
@@ -590,8 +595,8 @@ int skip_type(unsigned int type, buffer *d,
...
@@ -590,8 +595,8 @@ int skip_type(unsigned int type, buffer *d,
skipped
+=
len
+
4
;
skipped
+=
len
+
4
;
break
;}
break
;}
case
ARRAY_DECL
:
case
ARRAY_DECL
:
printf
(
"array
\n
"
);
skipped
+=
skip_array
(
d
,
sig
,
len
,
pos
);
skipped
+=
skip_array
(
d
,
sig
,
len
,
pos
);
break
;
case
STRUCT_DECL
:
case
STRUCT_DECL
:
skipped
+=
skip_struct
(
d
,
sig
,
len
,
pos
);
skipped
+=
skip_struct
(
d
,
sig
,
len
,
pos
);
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment