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
65e11f0b
Commit
65e11f0b
authored
Sep 02, 2020
by
Claes
Committed by
Esteban Blanc
Dec 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pwrp_alias, alias tag modification
parent
5107b0a0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
25 deletions
+124
-25
src/lib/rt/src/rt_ini_alias.c
src/lib/rt/src/rt_ini_alias.c
+91
-11
src/lib/rt/src/rt_ini_alias.h
src/lib/rt/src/rt_ini_alias.h
+12
-3
src/lib/rt/src/rt_ini_load.c
src/lib/rt/src/rt_ini_load.c
+11
-11
src/lib/rt/src/rt_ini_load.h
src/lib/rt/src/rt_ini_load.h
+1
-0
src/lib/rt/src/rt_qini.c
src/lib/rt/src/rt_qini.c
+9
-0
No files found.
src/lib/rt/src/rt_ini_alias.c
View file @
65e11f0b
...
...
@@ -49,7 +49,8 @@
#include "rt_ini_msg.h"
#include "rt_ini_alias.h"
static
FILE
*
ini_datafile
;
static
FILE
*
ini_datafile
=
0
;
static
ini_sAlias
*
ini_aliaslist
=
0
;
static
int
ini_datafile_init
(
char
*
filename
);
...
...
@@ -57,6 +58,8 @@ static int ini_datafile_close();
static
int
ini_datafile_get_next
(
char
*
parameter
,
char
**
data
,
int
*
elements
);
static
int
ini_datafile_get_next_alias
(
char
*
node
,
char
*
alias
,
char
*
addr
);
static
int
ini_parse
(
char
*
instring
,
char
*
parse_char
,
char
*
inc_parse_char
,
char
*
outstr
,
int
max_rows
,
int
max_cols
);
...
...
@@ -68,28 +71,52 @@ static int ini_set_nodeattribute(char* attribute_str, char* value_str);
static
int
ini_set_plcscan
(
char
*
value_str
);
pwr_tStatus
ini_
GetAlias
(
char
*
filename
,
char
*
nodename
,
char
*
alias
name
)
pwr_tStatus
ini_
LoadAlias
(
char
*
file
name
)
{
pwr_tStatus
sts
;
char
*
aliasname_ptr
;
int
elements
;
ini_sAlias
a
,
*
ap
;
sts
=
ini_datafile_init
(
filename
);
if
(
EVEN
(
sts
))
return
sts
;
sts
=
ini_datafile_get_next
(
nodename
,
&
aliasname_ptr
,
&
elements
);
if
(
EVEN
(
sts
))
return
sts
;
strcpy
(
aliasname
,
(
char
*
)
aliasname_ptr
);
free
(
aliasname_ptr
);
while
(
ODD
(
ini_datafile_get_next_alias
(
a
.
nodename
,
a
.
alias
,
a
.
addr
)))
{
ap
=
(
ini_sAlias
*
)
calloc
(
1
,
sizeof
(
*
ap
));
memcpy
(
ap
,
&
a
,
sizeof
(
*
ap
));
ap
->
next
=
ini_aliaslist
;
ini_aliaslist
=
ap
;
}
ini_datafile_close
();
return
INI__SUCCESS
;
}
void
ini_FreeAlias
(
void
)
{
ini_sAlias
*
ap
,
*
nextap
;
for
(
ap
=
ini_aliaslist
;
ap
;
ap
=
nextap
)
{
nextap
=
ap
->
next
;
free
(
ap
);
}
ini_aliaslist
=
0
;
}
pwr_tStatus
ini_GetAlias
(
char
*
nodename
,
char
*
alias
,
char
*
addr
)
{
ini_sAlias
*
ap
;
for
(
ap
=
ini_aliaslist
;
ap
;
ap
=
ap
->
next
)
{
if
(
strcmp
(
nodename
,
ap
->
nodename
)
==
0
)
{
strcpy
(
alias
,
ap
->
alias
);
if
(
addr
)
strcpy
(
addr
,
ap
->
addr
);
return
INI__SUCCESS
;
}
}
return
0
;
/* INI__PARNOTFOUND; */
}
pwr_tStatus
ini_SetAttributeAfterPlc
(
char
*
filename
,
char
*
nodename
,
int
output
)
{
pwr_tStatus
sts
;
...
...
@@ -336,6 +363,59 @@ static int ini_datafile_get_next(char* parameter, char** data, int* elements)
return
INI__SUCCESS
;
}
/****************************************************************************
* Name: ini_datafile_get_next_alias()
*
* Type int
*
* Type Parameter IOGF Description
*
* Description:
*
**************************************************************************/
static
int
ini_datafile_get_next_alias
(
char
*
node
,
char
*
alias
,
char
*
addr
)
{
char
line
[
256
];
char
data_array
[
4
][
80
];
int
found
,
nr
=
0
,
sts
;
if
(
ini_datafile
==
0
)
return
0
;
found
=
0
;
while
(
1
)
{
/* Read one line */
sts
=
ini_read_line
(
line
,
sizeof
(
line
),
ini_datafile
);
if
(
EVEN
(
sts
))
break
;
if
(
line
[
0
]
==
'!'
)
continue
;
/* Parse the line */
nr
=
ini_parse
(
line
,
"=, "
,
""
,
(
char
*
)
data_array
,
sizeof
(
data_array
)
/
sizeof
(
data_array
[
0
]),
sizeof
(
data_array
[
0
]));
if
(
nr
==
0
)
continue
;
if
(
str_NoCaseStrcmp
(
data_array
[
0
],
"alias"
)
==
0
&&
nr
>
2
)
{
found
=
1
;
break
;
}
}
if
(
!
found
)
return
0
;
/* INI__PARNOTFOUND; */
strcpy
(
node
,
data_array
[
1
]);
strcpy
(
alias
,
data_array
[
2
]);
if
(
nr
>
3
)
strcpy
(
addr
,
data_array
[
3
]);
else
strcpy
(
addr
,
""
);
return
INI__SUCCESS
;
}
/*************************************************************************
*
* Name: ini_parse()
...
...
src/lib/rt/src/rt_ini_alias.h
View file @
65e11f0b
...
...
@@ -37,8 +37,17 @@
#ifndef rt_ini_alias_h
#define rt_ini_alias_h
int
ini_GetAlias
(
char
*
filename
,
char
*
nodename
,
char
*
aliasname
);
int
ini_SetAttributeAfterPlc
(
char
*
filename
,
char
*
nodename
,
int
output
);
int
ini_SetAttribute
(
char
*
filename
,
char
*
nodename
,
int
output
);
typedef
struct
s_alias
{
char
nodename
[
80
];
char
alias
[
80
];
char
addr
[
80
];
struct
s_alias
*
next
;
}
ini_sAlias
;
pwr_tStatus
ini_LoadAlias
(
char
*
filename
);
void
ini_FreeAlias
(
void
);
pwr_tStatus
ini_GetAlias
(
char
*
nodename
,
char
*
alias
,
char
*
addr
);
pwr_tStatus
ini_SetAttributeAfterPlc
(
char
*
filename
,
char
*
nodename
,
int
output
);
pwr_tStatus
ini_SetAttribute
(
char
*
filename
,
char
*
nodename
,
int
output
);
#endif
src/lib/rt/src/rt_ini_load.c
View file @
65e11f0b
...
...
@@ -686,31 +686,27 @@ ini_sContext* ini_CheckContext(pwr_tStatus* status, ini_sContext* cp)
{
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
if
(
!
cp
->
flags
.
b
.
aliasfile
)
sprintf
(
cp
->
aliasfile
.
name
,
dbs_cNameAlias
,
cp
->
dir
);
// str_ToLower(cp->aliasfile.name, cp->aliasfile.name);
ini_LoadDirectory
(
sts
,
cp
);
cp
->
nodefile
.
errcount
=
NULL
;
cp
->
nodefile
.
logOpenFail
=
errh_LogInfo
;
if
(
!
cp
->
flags
.
b
.
applfile
)
sprintf
(
cp
->
applfile
.
name
,
dbs_cNameAppl
,
cp
->
dir
,
cdh_Low
(
cp
->
node
name
),
sprintf
(
cp
->
applfile
.
name
,
dbs_cNameAppl
,
cp
->
dir
,
cdh_Low
(
cp
->
orig
name
),
cp
->
busid
);
// str_ToLower(cp->applfile.name, cp->applfile.name);
cp
->
applfile
.
errcount
=
NULL
;
cp
->
applfile
.
logOpenFail
=
errh_LogInfo
;
if
(
!
cp
->
flags
.
b
.
bootfile
)
sprintf
(
cp
->
bootfile
.
name
,
dbs_cNameBoot
,
cp
->
dir
,
cdh_Low
(
cp
->
node
name
),
sprintf
(
cp
->
bootfile
.
name
,
dbs_cNameBoot
,
cp
->
dir
,
cdh_Low
(
cp
->
orig
name
),
cp
->
busid
);
// str_ToLower(cp->bootfile.name, cp->bootfile.name);
cp
->
bootfile
.
errcount
=
&
cp
->
fatals
;
cp
->
bootfile
.
logOpenFail
=
errh_LogFatal
;
if
(
!
cp
->
flags
.
b
.
nodefile
)
sprintf
(
cp
->
nodefile
.
name
,
dbs_cNameNode
,
cp
->
dir
,
cdh_Low
(
cp
->
node
name
),
sprintf
(
cp
->
nodefile
.
name
,
dbs_cNameNode
,
cp
->
dir
,
cdh_Low
(
cp
->
orig
name
),
cp
->
busid
);
// str_ToLower(cp->nodefile.name, cp->nodefile.name);
cp
->
nodefile
.
errcount
=
&
cp
->
fatals
;
...
...
@@ -755,9 +751,7 @@ ini_sContext* ini_CreateContext(pwr_tStatus* status)
return
cp
;
}
FILE
*
ini_OpenFile
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
ini_sFile
*
fp
)
FILE
*
ini_OpenFile
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
ini_sFile
*
fp
)
{
FILE
*
f
;
...
...
@@ -787,6 +781,8 @@ char* ini_LoadDirectory(pwr_tStatus* status, ini_sContext* cp)
if
(
!
cp
->
flags
.
b
.
hostname
)
syi_HostName
(
sts
,
cp
->
hostname
,
sizeof
(
cp
->
hostname
));
strcpy
(
cp
->
origname
,
cp
->
nodename
);
syi_NodeSpec
(
sts
,
cp
->
nodespec
,
sizeof
(
cp
->
nodespec
));
syi_HostSpec
(
sts
,
cp
->
hostspec
,
sizeof
(
cp
->
hostspec
));
syi_BootDisk
(
sts
,
cp
->
bootdisk
,
sizeof
(
cp
->
bootdisk
));
...
...
@@ -813,8 +809,12 @@ char* ini_LoadDirectory(pwr_tStatus* status, ini_sContext* cp)
cp
->
busid
=
atoi
(
s
);
}
}
if
(
!
cp
->
flags
.
b
.
aliasfile
)
sprintf
(
cp
->
aliasfile
.
name
,
dbs_cNameAlias
,
cp
->
dir
);
*
sts
=
ini_GetAlias
(
cp
->
aliasfile
.
name
,
cp
->
nodename
,
cp
->
alias
);
*
sts
=
ini_LoadAlias
(
cp
->
aliasfile
.
name
);
if
(
ODD
(
*
sts
))
*
sts
=
ini_GetAlias
(
cp
->
nodename
,
cp
->
alias
,
0
);
if
(
ODD
(
*
sts
))
{
errh_LogInfo
(
&
cp
->
log
,
"Alias defined to %s for this node %s"
,
cp
->
alias
,
cp
->
nodename
);
...
...
src/lib/rt/src/rt_ini_load.h
View file @
65e11f0b
...
...
@@ -124,6 +124,7 @@ typedef struct {
ini_mContext
flags
;
char
alias
[
80
];
char
nodename
[
80
];
char
origname
[
80
];
char
nodespec
[
80
];
char
hostname
[
80
];
char
hostspec
[
80
];
...
...
src/lib/rt/src/rt_qini.c
View file @
65e11f0b
...
...
@@ -44,6 +44,7 @@
#include "rt_errh.h"
#include "rt_qini.h"
#include "rt_net.h"
#include "rt_ini_alias.h"
static
qdb_sNode
*
addNode
(
qini_sNode
*
nep
)
{
...
...
@@ -145,6 +146,8 @@ int qini_ParseFile(
char
s_is_secondary
[
20
];
char
secondary_name
[
80
];
char
s_secondary_naddr
[
80
];
char
alias
[
80
];
char
alias_naddr
[
80
];
pwr_tNodeId
nid
;
struct
in_addr
naddr
;
qini_sNode
*
nep
;
...
...
@@ -168,6 +171,12 @@ int qini_ParseFile(
continue
;
}
sts
=
ini_GetAlias
(
name
,
alias
,
alias_naddr
);
if
(
ODD
(
sts
))
{
strcpy
(
name
,
alias
);
strcpy
(
s_naddr
,
alias_naddr
);
}
sts
=
cdh_StringToVolumeId
(
s_nid
,
(
pwr_tVolumeId
*
)
&
nid
);
if
(
EVEN
(
sts
))
{
errh_Error
(
...
...
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