Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
b8a44726
Commit
b8a44726
authored
Feb 23, 2006
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Function for delete of extern variables, and '#' for comment in script
parent
fff31e81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
292 additions
and
5 deletions
+292
-5
src/lib/co/src/co_ccm.c
src/lib/co/src/co_ccm.c
+270
-4
src/lib/co/src/co_ccm.h
src/lib/co/src/co_ccm.h
+22
-1
No files found.
src/lib/co/src/co_ccm.c
View file @
b8a44726
/**
/**
* Proview $Id: co_ccm.c,v 1.
4 2005-10-25 15:28:10
claes Exp $
* Proview $Id: co_ccm.c,v 1.
5 2006-02-23 14:34:59
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -93,6 +93,7 @@
...
@@ -93,6 +93,7 @@
#define K_ACTION_FUNCTION 43
#define K_ACTION_FUNCTION 43
#define K_ACTION_RETURN 44
#define K_ACTION_RETURN 44
#define K_ACTION_BACKSLASH 45
#define K_ACTION_BACKSLASH 45
#define K_ACTION_DELETE 46
#define K_OPERAND_NO 0
#define K_OPERAND_NO 0
#define K_OPERAND_NAME 1
#define K_OPERAND_NAME 1
...
@@ -102,6 +103,7 @@
...
@@ -102,6 +103,7 @@
#define K_OPERAND_EXTERN 5
#define K_OPERAND_EXTERN 5
#define K_OPERAND_FUNCTION 6
#define K_OPERAND_FUNCTION 6
#define K_OPERAND_RETURN 7
#define K_OPERAND_RETURN 7
#define K_OPERAND_DELETE 8
#define K_LOCTYPE_NO 0
#define K_LOCTYPE_NO 0
#define K_LOCTYPE_BEFORE 1
#define K_LOCTYPE_BEFORE 1
...
@@ -301,6 +303,12 @@ static int ccm_createvar(
...
@@ -301,6 +303,12 @@ static int ccm_createvar(
ccm_s_floatvar
**
floatlist
,
ccm_s_floatvar
**
floatlist
,
ccm_s_stringvar
**
stringlist
ccm_s_stringvar
**
stringlist
);
);
static
int
ccm_deletevar
(
char
*
name
,
ccm_s_intvar
**
intlist
,
ccm_s_floatvar
**
floatlist
,
ccm_s_stringvar
**
stringlist
);
static
int
ccm_function_exec
(
static
int
ccm_function_exec
(
ccm_t_file_ctx
ctx
,
ccm_t_file_ctx
ctx
,
char
*
name
,
char
*
name
,
...
@@ -1184,6 +1192,12 @@ static int operand_found( t_row_ctx rowctx)
...
@@ -1184,6 +1192,12 @@ static int operand_found( t_row_ctx rowctx)
operand_p
->
operator
=
K_ACTION_NO
;
operand_p
->
operator
=
K_ACTION_NO
;
rowctx
->
last_type
=
K_TYPE_OPERATOR
;
rowctx
->
last_type
=
K_TYPE_OPERATOR
;
}
}
else
if
(
strcmp
(
upname
,
"DELETE"
)
==
0
)
{
operand_p
->
type
=
K_OPERAND_DELETE
;
operand_p
->
operator
=
K_ACTION_DELETE
;
rowctx
->
last_type
=
K_TYPE_OPERATOR
;
}
else
if
(
strcmp
(
upname
,
"RETURN"
)
==
0
)
else
if
(
strcmp
(
upname
,
"RETURN"
)
==
0
)
{
{
operand_p
->
type
=
K_OPERAND_RETURN
;
operand_p
->
type
=
K_OPERAND_RETURN
;
...
@@ -2566,16 +2580,27 @@ int ccm_operate_exec(
...
@@ -2566,16 +2580,27 @@ int ccm_operate_exec(
case
K_ACTION_CREAEXTINT
:
case
K_ACTION_CREAEXTINT
:
sts
=
ccm_createvar
(
next
->
name
,
K_DECL_INT
,
0
,
0
,
NULL
,
sts
=
ccm_createvar
(
next
->
name
,
K_DECL_INT
,
0
,
0
,
NULL
,
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
if
(
sts
==
CCM__VARALREXIST
)
sts
=
CCM__SUCCESS
;
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
break
;
break
;
case
K_ACTION_CREAEXTFLOAT
:
case
K_ACTION_CREAEXTFLOAT
:
sts
=
ccm_createvar
(
next
->
name
,
K_DECL_FLOAT
,
0
,
0
,
NULL
,
sts
=
ccm_createvar
(
next
->
name
,
K_DECL_FLOAT
,
0
,
0
,
NULL
,
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
if
(
sts
==
CCM__VARALREXIST
)
sts
=
CCM__SUCCESS
;
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
break
;
break
;
case
K_ACTION_CREAEXTSTRING
:
case
K_ACTION_CREAEXTSTRING
:
sts
=
ccm_createvar
(
next
->
name
,
K_DECL_STRING
,
0
,
0
,
""
,
sts
=
ccm_createvar
(
next
->
name
,
K_DECL_STRING
,
0
,
0
,
""
,
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
if
(
sts
==
CCM__VARALREXIST
)
sts
=
CCM__SUCCESS
;
if
(
EVEN
(
sts
))
return
sts
;
break
;
case
K_ACTION_DELETE
:
sts
=
ccm_deletevar
(
next
->
name
,
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
EVEN
(
sts
))
return
sts
;
break
;
break
;
}
}
...
@@ -3173,7 +3198,157 @@ int ccm_set_external_var(
...
@@ -3173,7 +3198,157 @@ int ccm_set_external_var(
}
}
}
}
if
(
found
)
if
(
found
)
strncpy
(
string_p
->
value
+
element
*
K_STRING_SIZE
,
value_string
,
sizeof
(
string_p
->
value
));
strncpy
(
string_p
->
value
+
element
*
K_STRING_SIZE
,
value_string
,
K_STRING_SIZE
);
}
if
(
!
found
)
return
CCM__VARNOTFOUND
;
return
1
;
}
int
ccm_get_external_var
(
char
*
name
,
int
decl
,
float
*
value_float
,
int
*
value_int
,
char
*
value_string
)
{
ccm_s_intvar
*
int_p
;
ccm_s_floatvar
*
float_p
;
ccm_s_stringvar
*
string_p
;
ccm_s_intvar
*
int_list
;
ccm_s_floatvar
*
float_list
;
ccm_s_stringvar
*
string_list
;
int
found
;
int
sts
;
int
array
;
int
element
;
char
varname
[
80
];
sts
=
ccm_varname_parse
(
NULL
,
name
,
varname
,
&
array
,
&
element
);
if
(
EVEN
(
sts
))
return
sts
;
found
=
0
;
if
(
decl
==
K_DECL_INT
)
{
int_list
=
extint_list
;
for
(
int_p
=
int_list
;
int_p
;
int_p
=
int_p
->
next
)
{
if
(
strcmp
(
int_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
break
;
}
}
if
(
found
)
*
value_int
=
*
(
int_p
->
value
+
element
);
}
else
if
(
decl
==
K_DECL_FLOAT
)
{
/* Search float */
float_list
=
extfloat_list
;
for
(
float_p
=
float_list
;
float_p
;
float_p
=
float_p
->
next
)
{
if
(
strcmp
(
float_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
break
;
}
}
if
(
found
)
*
value_float
=
*
(
float_p
->
value
+
element
);
}
else
if
(
decl
==
K_DECL_STRING
)
{
/* Search string */
string_list
=
extstring_list
;
for
(
string_p
=
string_list
;
string_p
;
string_p
=
string_p
->
next
)
{
if
(
strcmp
(
string_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
break
;
}
}
if
(
found
)
strncpy
(
value_string
,
string_p
->
value
+
element
*
K_STRING_SIZE
,
K_STRING_SIZE
);
}
if
(
!
found
)
return
CCM__VARNOTFOUND
;
return
1
;
}
int
ccm_ref_external_var
(
char
*
name
,
int
decl
,
void
**
valuep
)
{
ccm_s_intvar
*
int_p
;
ccm_s_floatvar
*
float_p
;
ccm_s_stringvar
*
string_p
;
ccm_s_intvar
*
int_list
;
ccm_s_floatvar
*
float_list
;
ccm_s_stringvar
*
string_list
;
int
found
;
int
sts
;
int
array
;
int
element
;
char
varname
[
80
];
sts
=
ccm_varname_parse
(
NULL
,
name
,
varname
,
&
array
,
&
element
);
if
(
EVEN
(
sts
))
return
sts
;
found
=
0
;
if
(
decl
==
K_DECL_INT
)
{
int_list
=
extint_list
;
for
(
int_p
=
int_list
;
int_p
;
int_p
=
int_p
->
next
)
{
if
(
strcmp
(
int_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
break
;
}
}
if
(
found
)
*
valuep
=
(
void
*
)(
int_p
->
value
+
element
);
}
else
if
(
decl
==
K_DECL_FLOAT
)
{
/* Search float */
float_list
=
extfloat_list
;
for
(
float_p
=
float_list
;
float_p
;
float_p
=
float_p
->
next
)
{
if
(
strcmp
(
float_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
break
;
}
}
if
(
found
)
*
valuep
=
(
void
*
)(
float_p
->
value
+
element
);
}
else
if
(
decl
==
K_DECL_STRING
)
{
/* Search string */
string_list
=
extstring_list
;
for
(
string_p
=
string_list
;
string_p
;
string_p
=
string_p
->
next
)
{
if
(
strcmp
(
string_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
break
;
}
}
if
(
found
)
*
valuep
=
(
void
*
)
(
string_p
->
value
+
element
*
K_STRING_SIZE
);
}
}
if
(
!
found
)
if
(
!
found
)
return
CCM__VARNOTFOUND
;
return
CCM__VARNOTFOUND
;
...
@@ -3261,6 +3436,84 @@ static int ccm_createvar(
...
@@ -3261,6 +3436,84 @@ static int ccm_createvar(
return
1
;
return
1
;
}
}
static
int
ccm_deletevar
(
char
*
name
,
ccm_s_intvar
**
int_list
,
ccm_s_floatvar
**
float_list
,
ccm_s_stringvar
**
string_list
)
{
ccm_s_intvar
*
int_p
,
*
int_prev
;
ccm_s_floatvar
*
float_p
,
*
float_prev
;
ccm_s_stringvar
*
string_p
,
*
string_prev
;
int
array
;
int
elements
;
char
varname
[
80
];
int
sts
;
int
found
;
sts
=
ccm_varname_parse
(
NULL
,
name
,
varname
,
&
array
,
&
elements
);
if
(
EVEN
(
sts
))
return
sts
;
elements
++
;
int_prev
=
0
;
found
=
0
;
for
(
int_p
=
*
int_list
;
int_p
;
int_p
=
int_p
->
next
)
{
if
(
strcmp
(
int_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
if
(
!
int_prev
)
*
int_list
=
int_p
->
next
;
else
int_prev
->
next
=
int_p
->
next
;
free
(
int_p
->
value
);
free
(
int_p
);
break
;
}
int_prev
=
int_p
;
}
if
(
found
)
return
1
;
float_prev
=
0
;
for
(
float_p
=
*
float_list
;
float_p
;
float_p
=
float_p
->
next
)
{
if
(
strcmp
(
float_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
if
(
!
float_prev
)
*
float_list
=
float_p
->
next
;
else
float_prev
->
next
=
float_p
->
next
;
free
(
float_p
->
value
);
free
(
float_p
);
break
;
}
float_prev
=
float_p
;
}
if
(
found
)
return
1
;
string_prev
=
0
;
for
(
string_p
=
*
string_list
;
string_p
;
string_p
=
string_p
->
next
)
{
if
(
strcmp
(
string_p
->
name
,
varname
)
==
0
)
{
found
=
1
;
if
(
!
string_prev
)
*
string_list
=
string_p
->
next
;
else
string_prev
->
next
=
string_p
->
next
;
free
(
string_p
->
value
);
free
(
string_p
);
break
;
}
string_prev
=
string_p
;
}
if
(
!
found
)
return
CCM__VARNOTFOUND
;
return
1
;
}
int
ccm_create_external_var
(
int
ccm_create_external_var
(
char
*
name
,
char
*
name
,
int
decl
,
int
decl
,
...
@@ -3273,8 +3526,21 @@ int ccm_create_external_var(
...
@@ -3273,8 +3526,21 @@ int ccm_create_external_var(
sts
=
ccm_createvar
(
name
,
decl
,
value_float
,
value_int
,
value_string
,
sts
=
ccm_createvar
(
name
,
decl
,
value_float
,
value_int
,
value_string
,
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
if
(
sts
==
CCM__VARALREXIST
)
return
CCM__SUCCESS
;
return
sts
;
return
sts
;
}
}
int
ccm_delete_external_var
(
char
*
name
,
float
value_float
,
int
value_int
,
char
*
value_string
)
{
return
ccm_deletevar
(
name
,
&
extint_list
,
&
extfloat_list
,
&
extstring_list
);
}
static
int
ccm_read_file
(
static
int
ccm_read_file
(
ccm_t_file_ctx
filectx
,
ccm_t_file_ctx
filectx
,
char
*
filename
,
char
*
filename
,
...
@@ -3306,7 +3572,7 @@ static int ccm_read_file(
...
@@ -3306,7 +3572,7 @@ static int ccm_read_file(
{
{
row
++
;
row
++
;
ccm_remove_blank
(
str
,
str
);
ccm_remove_blank
(
str
,
str
);
if
(
str
[
0
]
==
'!'
)
if
(
str
[
0
]
==
'!'
||
str
[
0
]
==
'#'
)
continue
;
continue
;
/* If last char i backslash, concatenate next line */
/* If last char i backslash, concatenate next line */
while
(
str
[
strlen
(
str
)
-
1
]
==
'\\'
)
while
(
str
[
strlen
(
str
)
-
1
]
==
'\\'
)
...
@@ -3320,7 +3586,7 @@ static int ccm_read_file(
...
@@ -3320,7 +3586,7 @@ static int ccm_read_file(
}
}
row
++
;
row
++
;
ccm_remove_blank
(
str2
,
str2
);
ccm_remove_blank
(
str2
,
str2
);
if
(
str2
[
0
]
==
'!'
)
if
(
str2
[
0
]
==
'!'
||
str2
[
0
]
==
'#'
)
continue
;
continue
;
str
[
strlen
(
str
)
-
1
]
=
0
;
str
[
strlen
(
str
)
-
1
]
=
0
;
if
(
strlen
(
str
)
+
strlen
(
str2
)
>
K_LINE_SIZE
-
1
)
if
(
strlen
(
str
)
+
strlen
(
str2
)
>
K_LINE_SIZE
-
1
)
...
...
src/lib/co/src/co_ccm.h
View file @
b8a44726
/**
/**
* Proview $Id: co_ccm.h,v 1.
4 2005-10-25 15:28:10
claes Exp $
* Proview $Id: co_ccm.h,v 1.
5 2006-02-23 14:34:59
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
* Copyright (C) 2005 SSAB Oxelsund AB.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
...
@@ -77,6 +77,13 @@ int ccm_create_external_var(
...
@@ -77,6 +77,13 @@ int ccm_create_external_var(
char
*
value_string
char
*
value_string
);
);
int
ccm_delete_external_var
(
char
*
name
,
float
value_float
,
int
value_int
,
char
*
value_string
);
int
ccm_set_external_var
(
int
ccm_set_external_var
(
char
*
name
,
char
*
name
,
int
decl
,
int
decl
,
...
@@ -85,6 +92,20 @@ int ccm_set_external_var(
...
@@ -85,6 +92,20 @@ int ccm_set_external_var(
char
*
value_string
char
*
value_string
);
);
int
ccm_get_external_var
(
char
*
name
,
int
decl
,
float
*
value_float
,
int
*
value_int
,
char
*
value_string
);
int
ccm_ref_external_var
(
char
*
name
,
int
decl
,
void
**
valuep
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
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