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
7a20e851
Commit
7a20e851
authored
Sep 05, 2008
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work on sev
parent
532e423f
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
2904 additions
and
93 deletions
+2904
-93
sev/exe/sev_ini/src/ini.c
sev/exe/sev_ini/src/ini.c
+552
-0
sev/exe/sev_ini/src/ini.h
sev/exe/sev_ini/src/ini.h
+179
-0
sev/exe/sev_ini/src/os_linux/hw_x86/makefile
sev/exe/sev_ini/src/os_linux/hw_x86/makefile
+12
-0
sev/exe/sev_ini/src/os_linux/link_rule.mk
sev/exe/sev_ini/src/os_linux/link_rule.mk
+17
-0
sev/exe/sev_ini/src/sev_ini.c
sev/exe/sev_ini/src/sev_ini.c
+433
-0
sev/exe/sev_server/src/sev_server.cpp
sev/exe/sev_server/src/sev_server.cpp
+77
-17
sev/exe/sev_server/src/sev_server.h
sev/exe/sev_server/src/sev_server.h
+2
-1
sev/exe/sev_xtt/gtk/os_linux/link_rule.mk
sev/exe/sev_xtt/gtk/os_linux/link_rule.mk
+1
-1
sev/exe/sev_xtt/gtk/sev_xtt_gtk.cpp
sev/exe/sev_xtt/gtk/sev_xtt_gtk.cpp
+22
-5
sev/exe/sev_xtt/gtk/xtt_tbl_gtk.cpp
sev/exe/sev_xtt/gtk/xtt_tbl_gtk.cpp
+358
-31
sev/exe/sev_xtt/gtk/xtt_tbl_gtk.h
sev/exe/sev_xtt/gtk/xtt_tbl_gtk.h
+30
-1
sev/exe/sev_xtt/src/xtt_tbl.cpp
sev/exe/sev_xtt/src/xtt_tbl.cpp
+142
-2
sev/exe/sev_xtt/src/xtt_tbl.h
sev/exe/sev_xtt/src/xtt_tbl.h
+47
-5
sev/exe/sev_xtt/src/xtt_tbl_command.cpp
sev/exe/sev_xtt/src/xtt_tbl_command.cpp
+557
-0
sev/exe/sev_xtt/src/xtt_tblnav.cpp
sev/exe/sev_xtt/src/xtt_tblnav.cpp
+331
-19
sev/exe/sev_xtt/src/xtt_tblnav.h
sev/exe/sev_xtt/src/xtt_tblnav.h
+74
-7
sev/lib/sev/src/sev_db.h
sev/lib/sev/src/sev_db.h
+4
-2
sev/lib/sev/src/sev_dbms.cpp
sev/lib/sev/src/sev_dbms.cpp
+62
-1
sev/lib/sev/src/sev_dbms.h
sev/lib/sev/src/sev_dbms.h
+4
-1
No files found.
sev/exe/sev_ini/src/ini.c
0 → 100644
View file @
7a20e851
/*
* Proview $Id: ini.c,v 1.1 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <ctype.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "co_dbs.h"
#include "co_tree.h"
#include "co_time.h"
#include "co_errno.h"
#include "rt_qcom.h"
#include "ini.h"
#include "rt_ini_msg.h"
#include "rt_lst.h"
#include "rt_errh.h"
#include "co_syi.h"
#define cPrio_base 0
#define cPrio_qmon (cPrio_base + 19)
#define cPrio_sev_server (cPrio_base + 6)
static
char
*
strsav
(
char
*
);
static
char
*
strsav
(
char
*
s
)
{
int
len
;
char
*
t
=
NULL
;
if
(
s
==
NULL
)
return
NULL
;
len
=
strlen
(
s
);
if
(
len
>
0
)
{
t
=
malloc
(
len
+
1
);
strcpy
(
t
,
s
);
}
return
t
;
}
ini_sContext
*
ini_CheckContext
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
)
{
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
ini_LoadDirectory
(
sts
,
cp
);
if
(
!
cp
->
flags
.
b
.
aliasfile
)
sprintf
(
cp
->
aliasfile
.
name
,
dbs_cNameAlias
,
cp
->
dir
);
cdh_ToLower
(
cp
->
aliasfile
.
name
,
cp
->
aliasfile
.
name
);
cp
->
nodefile
.
errcount
=
NULL
;
cp
->
nodefile
.
logOpenFail
=
errh_LogInfo
;
if
(
!
cp
->
flags
.
b
.
applfile
)
sprintf
(
cp
->
applfile
.
name
,
dbs_cNameAppl
,
cp
->
dir
,
cp
->
nodename
,
cp
->
busid
);
cdh_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
,
cp
->
nodename
,
cp
->
busid
);
cdh_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
,
cp
->
nodename
,
cp
->
busid
);
cdh_ToLower
(
cp
->
nodefile
.
name
,
cp
->
nodefile
.
name
);
cp
->
nodefile
.
errcount
=
&
cp
->
fatals
;
cp
->
nodefile
.
logOpenFail
=
errh_LogFatal
;
return
cp
;
}
ini_sContext
*
ini_CreateContext
(
pwr_tStatus
*
status
)
{
ini_sContext
*
cp
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
cp
=
calloc
(
1
,
sizeof
(
*
cp
));
if
(
cp
==
NULL
)
return
NULL
;
cp
->
nid_t
=
tree_CreateTable
(
sts
,
sizeof
(
pwr_tNodeId
),
offsetof
(
qini_sNode
,
nid
),
sizeof
(
qini_sNode
),
10
,
tree_Comp_nid
);
cp
->
proc_t
=
tree_CreateTable
(
sts
,
sizeof
(((
ini_sProc
*
)
0
)
->
id
),
offsetof
(
ini_sProc
,
id
),
sizeof
(
ini_sProc
),
10
,
tree_Comp_strncmp
);
lst_Init
(
NULL
,
&
cp
->
proc_lh
,
NULL
);
co_GetOwnFormat
(
&
cp
->
format
);
return
cp
;
}
FILE
*
ini_OpenFile
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
ini_sFile
*
fp
)
{
FILE
*
f
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
f
=
fopen
(
fp
->
name
,
"r"
);
if
(
f
==
NULL
)
{
if
(
fp
->
errcount
)
(
*
fp
->
errcount
)
++
;
if
(
fp
->
logOpenFail
)
fp
->
logOpenFail
(
&
cp
->
log
,
"Could not open file %s"
,
fp
->
name
);
return
NULL
;
}
if
(
cp
->
flags
.
b
.
verbose
)
errh_LogInfo
(
&
cp
->
log
,
"Opened file %s"
,
fp
->
name
);
return
f
;
}
char
*
ini_LoadDirectory
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
)
{
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
if
(
!
cp
->
flags
.
b
.
nodename
)
syi_NodeName
(
sts
,
cp
->
nodename
,
sizeof
(
cp
->
nodename
));
if
(
!
cp
->
flags
.
b
.
hostname
)
syi_HostName
(
sts
,
cp
->
hostname
,
sizeof
(
cp
->
hostname
));
syi_NodeSpec
(
sts
,
cp
->
nodespec
,
sizeof
(
cp
->
nodespec
));
syi_HostSpec
(
sts
,
cp
->
hostspec
,
sizeof
(
cp
->
hostspec
));
syi_BootDisk
(
sts
,
cp
->
bootdisk
,
sizeof
(
cp
->
bootdisk
));
{
char
*
s
;
if
((
s
=
getenv
(
dbs_cNameBaseDirectory
))
!=
NULL
)
sprintf
(
cp
->
bdir
,
"%s/"
,
s
);
else
errh_LogError
(
&
cp
->
log
,
"Environment variable '%s' is not defined"
,
dbs_cNameBaseDirectory
);
if
((
s
=
getenv
(
dbs_cNameDirectory
))
!=
NULL
)
sprintf
(
cp
->
dir
,
"%s/"
,
s
);
else
errh_LogError
(
&
cp
->
log
,
"Environment variable '%s' is not defined"
,
dbs_cNameDirectory
);
if
(
!
cp
->
flags
.
b
.
busid
)
{
s
=
getenv
(
pwr_dEnvBusId
);
if
(
s
!=
NULL
)
cp
->
busid
=
atoi
(
s
);
}
}
return
cp
->
dir
;
}
void
ini_ReadBootFile
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
)
{
char
day
[
80
];
char
time
[
80
];
char
buffer
[
256
];
char
*
s
;
int
i
;
int
n
;
int
nvol
;
/* pwr_tProjVersion ver;*/
FILE
*
f
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
f
=
ini_OpenFile
(
sts
,
cp
,
&
cp
->
bootfile
);
if
(
f
==
NULL
)
return
;
errh_LogInfo
(
&
cp
->
log
,
"Reading Boot file %s"
,
cp
->
bootfile
.
name
);
for
(
i
=
0
,
nvol
=
0
,
s
=
fgets
(
buffer
,
sizeof
(
buffer
)
-
1
,
f
);
s
!=
NULL
;
s
=
fgets
(
buffer
,
sizeof
(
buffer
)
-
1
,
f
)
)
{
if
(
*
s
==
'!'
)
{
s
++
;
continue
;
}
switch
(
i
)
{
case
0
:
/* Creation Date. */
i
++
;
time
[
0
]
=
day
[
0
]
=
'\0'
;
n
=
sscanf
(
s
,
"%s %s"
,
day
,
time
);
break
;
case
1
:
i
++
;
cp
->
proj
[
0
]
=
'\0'
;
n
=
sscanf
(
s
,
"%s"
,
cp
->
proj
);
errh_LogInfo
(
&
cp
->
log
,
"Created at %s %s for project: %s"
,
day
,
time
,
cp
->
proj
);
break
;
case
2
:
i
++
;
cp
->
group
[
0
]
=
'\0'
;
n
=
sscanf
(
s
,
"%s"
,
cp
->
group
);
break
;
}
}
fclose
(
f
);
}
pwr_tBoolean
ini_ReadNodeFile
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
)
{
FILE
*
f
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
f
=
ini_OpenFile
(
sts
,
cp
,
&
cp
->
nodefile
);
if
(
f
==
NULL
)
return
NO
;
errh_LogInfo
(
&
cp
->
log
,
"Reading Node file %s"
,
cp
->
nodefile
.
name
);
qini_ParseFile
(
f
,
cp
->
nid_t
,
&
cp
->
warnings
,
&
cp
->
errors
,
&
cp
->
fatals
);
fclose
(
f
);
return
YES
;
}
ini_sProc
*
ini_ProcInsert
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
char
*
id
,
char
*
name
,
int
load
,
int
run
,
char
*
file
,
int
prio
,
int
debug
,
char
*
arg
)
{
ini_sProc
*
pp
;
char
buf
[
255
];
char
*
s
;
int
ret
;
struct
stat
f_stat
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
pp
=
tree_Insert
(
sts
,
cp
->
proc_t
,
id
);
if
(
pp
==
NULL
)
return
NULL
;
if
(
name
!=
NULL
&&
name
[
0
]
!=
'\0'
&&
strcmp
(
name
,
"
\"\"
"
))
{
if
(
pp
->
proc
.
name
!=
NULL
)
free
(
pp
->
proc
.
name
);
sprintf
(
buf
,
name
,
cp
->
busid
);
pp
->
proc
.
name
=
strsav
(
buf
);
}
if
(
load
!=
-
1
)
pp
->
proc
.
flags
.
b
.
load
=
load
!=
0
;
if
(
run
!=
-
1
)
pp
->
flags
.
b
.
run
=
run
!=
0
;
if
(
file
!=
NULL
&&
file
[
0
]
!=
'\0'
&&
strcmp
(
file
,
"
\"\"
"
))
{
if
(
pp
->
proc
.
file
!=
NULL
)
free
(
pp
->
proc
.
file
);
pp
->
proc
.
file
=
strsav
(
file
);
#if defined(OS_LINUX)
s
=
getenv
(
"pwr_exe"
);
sprintf
(
buf
,
"%s/%s"
,
s
,
file
);
ret
=
stat
(
buf
,
&
f_stat
);
if
(
ret
==
-
1
)
{
s
=
getenv
(
"pwrp_exe"
);
sprintf
(
buf
,
"%s/%s"
,
s
,
file
);
ret
=
stat
(
buf
,
&
f_stat
);
if
(
ret
==
-
1
)
{
pp
->
flags
.
b
.
run
=
0
;
pp
->
proc
.
flags
.
b
.
load
=
0
;
}
}
#endif
}
if
(
arg
!=
NULL
&&
arg
[
0
]
!=
'\0'
&&
strcmp
(
arg
,
"
\"\"
"
))
{
if
(
pp
->
proc
.
arg
!=
NULL
)
free
(
pp
->
proc
.
arg
);
pp
->
proc
.
arg
=
strsav
(
arg
);
}
if
(
prio
!=
-
1
)
pp
->
proc
.
p_prio
=
prio
;
if
(
debug
!=
-
1
)
pp
->
proc
.
flags
.
b
.
debug
=
debug
!=
0
;
if
(
!
lst_IsLinked
(
NULL
,
&
pp
->
proc_ll
))
{
lst_InsertPred
(
NULL
,
&
cp
->
proc_lh
,
&
pp
->
proc_ll
,
pp
);
}
return
pp
;
}
void
ini_ProcStart
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
ini_sProc
*
pp
)
{
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
if
(
pp
->
flags
.
b
.
running
)
return
;
if
(
pp
->
flags
.
b
.
run
)
{
errh_LogInfo
(
&
cp
->
log
,
"Starting %s, file: %s, prio: %d"
,
pp
->
id
,
pp
->
proc
.
file
,
pp
->
proc
.
p_prio
);
}
else
{
errh_LogInfo
(
&
cp
->
log
,
"%s, file: %s, prio: %d, will not be started."
,
pp
->
id
,
pp
->
proc
.
file
,
pp
->
proc
.
p_prio
);
return
;
}
*
sts
=
proc_Start
(
&
pp
->
proc
);
if
(
EVEN
(
*
sts
))
errh_LogError
(
&
cp
->
log
,
"Error starting %s, %m"
,
pp
->
id
,
*
sts
);
}
void
ini_ProcPrio
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
ini_sProc
*
pp
)
{
char
set
[
100
];
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
if
(
pp
->
flags
.
b
.
running
)
return
;
if
(
pp
->
flags
.
b
.
run
)
{
#if defined(OS_LINUX)
if
(
!
(
pp
->
flags
.
b
.
plc
))
{
sprintf
(
set
,
"rt_prio -rp %d %d"
,
pp
->
proc
.
p_prio
,
pp
->
proc
.
pid
);
system
(
set
);
}
#endif
}
}
void
ini_ProcIter
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
,
int
mask
,
void
(
*
func
)(
pwr_tStatus
*
,
ini_sContext
*
,
ini_sProc
*
)
)
{
lst_sEntry
*
pl
;
ini_sProc
*
pp
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
for
(
pp
=
lst_Succ
(
NULL
,
&
cp
->
proc_lh
,
&
pl
);
pp
!=
NULL
;
pp
=
lst_Succ
(
NULL
,
pl
,
&
pl
))
{
if
(
pp
->
proc
.
flags
.
m
&
mask
)
func
(
sts
,
cp
,
pp
);
}
}
void
ini_ProcTable
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
)
{
FILE
*
f
;
ini_sProc
*
pp
;
char
*
s
;
char
buffer
[
256
];
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
pp
=
ini_ProcInsert
(
sts
,
cp
,
"pwr_qmon"
,
"pwr_qmon_%d"
,
0
,
1
,
"rt_qmon"
,
cPrio_qmon
,
0
,
"-n"
);
pp
->
flags
.
b
.
qmon
=
1
;
pp
->
proc
.
flags
.
b
.
system
=
1
;
pp
=
ini_ProcInsert
(
sts
,
cp
,
"pwr_sev_server"
,
"pwr_sev_server_%d"
,
0
,
1
,
"sev_server"
,
cPrio_sev_server
,
0
,
""
);
pp
->
proc
.
flags
.
b
.
system
=
1
;
f
=
ini_OpenFile
(
sts
,
cp
,
&
cp
->
applfile
);
if
(
f
!=
NULL
)
{
if
(
cp
->
flags
.
b
.
verbose
)
errh_LogInfo
(
&
cp
->
log
,
"Reading Application file %s
\n
"
,
cp
->
applfile
.
name
);
for
(;;)
{
char
*
nl
;
s
=
fgets
(
buffer
,
sizeof
(
buffer
)
-
1
,
f
);
if
(
s
==
NULL
)
break
;
nl
=
strchr
(
s
,
'\n'
);
if
(
nl
!=
NULL
)
*
nl
=
'\0'
;
if
(
cp
->
flags
.
b
.
verbose
)
errh_LogInfo
(
&
cp
->
log
,
" %s"
,
buffer
);
if
(
buffer
[
0
]
==
'#'
)
continue
;
do
{
int
i_load
=
-
1
;
int
i_run
=
-
1
;
int
i_debug
=
-
1
;
int
i_prio
=
-
1
;
char
*
id
=
NULL
;
char
*
name
=
NULL
;
char
*
load
=
NULL
;
char
*
run
=
NULL
;
char
*
file
=
NULL
;
char
*
prio
=
NULL
;
char
*
debug
=
NULL
;
char
*
arg
=
NULL
;
id
=
strtok
(
s
,
","
);
if
(
id
==
NULL
)
break
;
name
=
strtok
(
NULL
,
","
);
if
(
name
==
NULL
)
break
;
load
=
strtok
(
NULL
,
","
);
if
(
load
==
NULL
)
break
;
run
=
strtok
(
NULL
,
","
);
if
(
run
==
NULL
)
break
;
file
=
strtok
(
NULL
,
","
);
if
(
file
==
NULL
)
break
;
prio
=
strtok
(
NULL
,
","
);
if
(
prio
==
NULL
)
break
;
debug
=
strtok
(
NULL
,
","
);
if
(
debug
==
NULL
)
break
;
arg
=
strtok
(
NULL
,
","
);
if
(
arg
==
NULL
)
break
;
while
(
isspace
(
*
id
))
id
++
;
while
(
isspace
(
*
name
))
name
++
;
while
(
isspace
(
*
load
))
load
++
;
while
(
isspace
(
*
run
))
run
++
;
while
(
isspace
(
*
file
))
file
++
;
while
(
isspace
(
*
prio
))
prio
++
;
while
(
isspace
(
*
debug
))
debug
++
;
while
(
isspace
(
*
arg
))
arg
++
;
if
(
id
[
0
]
==
'\0'
)
break
;
if
(
strstr
(
load
,
"no"
))
i_load
=
0
;
else
if
(
strstr
(
load
,
"load"
))
i_load
=
1
;
if
(
strstr
(
run
,
"no"
))
i_run
=
0
;
else
if
(
strstr
(
run
,
"run"
))
i_run
=
1
;
if
(
strstr
(
debug
,
"no"
))
i_debug
=
0
;
else
if
(
strstr
(
debug
,
"debug"
))
i_debug
=
1
;
if
(
strcspn
(
prio
,
"0123456789"
)
>
0
)
i_prio
=
-
1
;
else
i_prio
=
atoi
(
prio
);
pp
=
ini_ProcInsert
(
sts
,
cp
,
id
,
name
,
i_load
,
i_run
,
file
,
i_prio
,
i_debug
,
arg
);
if
(
!
pp
->
proc
.
flags
.
b
.
system
&&
!
pp
->
proc
.
flags
.
b
.
base
)
pp
->
proc
.
flags
.
b
.
user
=
1
;
}
while
(
0
);
}
fclose
(
f
);
}
}
void
ini_ProcWait
(
pwr_tStatus
*
status
,
ini_sContext
*
cp
)
{
lst_sEntry
*
pl
;
ini_sProc
*
pp
;
pid_t
pid
;
pid_t
last_pid
=
1
;
qcom_sGet
get
;
int
tmo
=
1000
;
pwr_dStatus
(
sts
,
status
,
INI__SUCCESS
);
#if defined OS_LYNX || defined OS_LINUX
for
(;;)
{
int
status
;
get
.
data
=
NULL
;
qcom_Get
(
sts
,
&
cp
->
eventQ
,
&
get
,
tmo
);
if
(
*
sts
==
QCOM__TMO
||
*
sts
==
QCOM__QEMPTY
)
{
errh_Info
(
"Timeout"
);
}
else
if
(
get
.
data
==
NULL
)
{
errh_Info
(
"Nulldata"
);
}
else
{
errh_Info
(
"%d %s"
,
get
.
size
,
get
.
data
);
qcom_Free
(
NULL
,
get
.
data
);
}
if
(
lst_Succ
(
NULL
,
&
cp
->
proc_lh
,
&
pl
)
==
NULL
)
break
;
pid
=
waitpid
(
-
1
,
&
status
,
WNOHANG
|
WUNTRACED
);
if
(
pid
==
0
)
continue
;
if
(
pid
==
last_pid
)
break
;
for
(
pp
=
lst_Succ
(
NULL
,
&
cp
->
proc_lh
,
&
pl
);
pp
!=
NULL
;
pp
=
lst_Succ
(
NULL
,
pl
,
&
pl
))
{
if
(
pp
->
proc
.
pid
==
pid
)
{
errh_Info
(
"Process %s exited with status %d"
,
pp
->
proc
.
name
,
status
);
break
;
}
}
}
#else
sleep
(
100000
);
#endif
errh_Info
(
"Ich sterbe!!"
);
}
sev/exe/sev_ini/src/ini.h
0 → 100644
View file @
7a20e851
/*
* Proview $Id: ini.h,v 1.1 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef ini_h
#define ini_h
#include "pwr.h"
#include "pwr_class.h"
#include "pwr_baseclasses.h"
#include "co_tree.h"
#include "co_dbs.h"
#include "rt_lst.h"
#include "rt_qini.h"
#include "rt_proc.h"
#include "rt_errh.h"
typedef
union
{
pwr_tBitMask
m
;
pwr_32Bits
(
pwr_Bits
(
ignoreWarning
,
1
),
pwr_Bits
(
ignoreError
,
1
),
pwr_Bits
(
ignoreFatal
,
1
),
pwr_Bits
(
verbose
,
1
),
pwr_Bits
(
restart
,
1
),
pwr_Bits
(
stop
,
1
),
pwr_Bits
(
fill_0
,
2
),,,
pwr_Bits
(
interactive
,
1
),
pwr_Bits
(
busid
,
1
),
pwr_Bits
(
hostname
,
1
),
pwr_Bits
(
nodename
,
1
),
pwr_Bits
(
fill_1
,
4
),,,,
pwr_Bits
(
applfile
,
1
),
pwr_Bits
(
aliasfile
,
1
),
pwr_Bits
(
bootfile
,
1
),
pwr_Bits
(
plcfile
,
1
),
pwr_Bits
(
nodefile
,
1
),
pwr_Bits
(
fill_2
,
3
),,,
pwr_Bits
(
fill_3
,
8
),,,,,,
)
b
;
#define ini_mContext__ 0
#define ini_mContext_ignoreWarning pwr_Bit(0)
#define ini_mContext_ignoreError pwr_Bit(1)
#define ini_mContext_ignoreFatal pwr_Bit(2)
#define ini_mContext_verbose pwr_Bit(3)
#define ini_mContext_restart pwr_Bit(4)
#define ini_mContext_stop pwr_Bit(5)
#define ini_mContext_interactive pwr_Bit(8)
#define ini_mContext_busid pwr_Bit(9)
#define ini_mContext_hostname pwr_Bit(10)
#define ini_mContext_nodename pwr_Bit(11)
#define ini_mContext_applfile pwr_Bit(16)
#define ini_mContext_aliasfile pwr_Bit(17)
#define ini_mContext_bootfile pwr_Bit(18)
#define ini_mContext_plcfile pwr_Bit(19)
#define ini_mContext_nodefile pwr_Bit(20)
#define ini_mContext_ (~ini_mContext__)
}
ini_mContext
;
typedef
union
{
pwr_tBitMask
m
;
pwr_32Bits
(
pwr_Bits
(
neth
,
1
),
pwr_Bits
(
qmon
,
1
),
pwr_Bits
(
plc
,
1
),
pwr_Bits
(
fill_0
,
5
),,,,,
pwr_Bits
(
run
,
1
),
pwr_Bits
(
running
,
1
),
pwr_Bits
(
reap
,
1
),
pwr_Bits
(
fill_1
,
5
),,,,,
pwr_Bits
(
fill_2
,
8
),,,,,,,,
pwr_Bits
(
inited
,
1
),
pwr_Bits
(
fill_3
,
8
),,,,,,
)
b
;
#define ini_mProc__ 0
#define ini_mProc_neth pwr_Bit(0)
#define ini_mProc_qmon pwr_Bit(1)
#define ini_mProc_plc pwr_Bit(2)
#define ini_mProc_run pwr_Bit(8)
#define ini_mProc_running pwr_Bit(9)
#define ini_mProc_reap pwr_Bit(10)
#define ini_mProc_inited pwr_Bit(24)
#define ini_mProc_ (~ini_mProc__)
}
ini_mProc
;
typedef
struct
{
char
name
[
256
];
int
*
errcount
;
void
(
*
logOpenFail
)(
errh_sLog
*
,
char
*
,
...);
}
ini_sFile
;
typedef
struct
{
tree_sNode
t
;
lst_sEntry
proc_ll
;
char
id
[
40
];
ini_mProc
flags
;
proc_sProcess
proc
;
}
ini_sProc
;
typedef
struct
{
ini_mContext
flags
;
char
alias
[
80
];
char
nodename
[
80
];
char
nodespec
[
80
];
char
hostname
[
80
];
char
hostspec
[
80
];
char
bootdisk
[
80
];
char
proj
[
80
];
char
group
[
80
];
char
console
[
80
];
ini_sFile
aliasfile
;
ini_sFile
applfile
;
ini_sFile
bootfile
;
ini_sFile
nodefile
;
int
busid
;
char
dir
[
256
];
char
bdir
[
256
];
/* Base dir (pwr_load) */
int
warnings
;
int
errors
;
int
fatals
;
qini_sNode
*
me
;
tree_sTable
*
nid_t
;
co_mFormat
format
;
dbs_sEnv
dbs
;
dbs_sSect
sect
;
tree_sTable
*
proc_t
;
lst_sEntry
proc_lh
;
ini_sProc
*
plc
;
qcom_sQid
myQ
;
qcom_sQid
yourQ
;
qcom_sQid
eventQ
;
errh_sLog
log
;
}
ini_sContext
;
ini_sContext
*
ini_CheckContext
(
pwr_tStatus
*
,
ini_sContext
*
);
ini_sContext
*
ini_CreateContext
(
pwr_tStatus
*
);
char
*
ini_LoadDirectory
(
pwr_tStatus
*
,
ini_sContext
*
);
FILE
*
ini_OpenFile
(
pwr_tStatus
*
,
ini_sContext
*
,
ini_sFile
*
);
ini_sProc
*
ini_ProcInsert
(
pwr_tStatus
*
,
ini_sContext
*
,
char
*
,
char
*
,
int
,
int
,
char
*
,
int
,
int
,
char
*
);
void
ini_ProcIter
(
pwr_tStatus
*
,
ini_sContext
*
,
int
,
void
(
*
func
)
(
pwr_tStatus
*
,
ini_sContext
*
,
ini_sProc
*
));
void
ini_ProcStart
(
pwr_tStatus
*
,
ini_sContext
*
,
ini_sProc
*
);
void
ini_ProcPrio
(
pwr_tStatus
*
,
ini_sContext
*
,
ini_sProc
*
);
void
ini_ProcTable
(
pwr_tStatus
*
,
ini_sContext
*
);
void
ini_ProcWait
(
pwr_tStatus
*
,
ini_sContext
*
);
void
ini_ReadBootFile
(
pwr_tStatus
*
,
ini_sContext
*
);
pwr_tBoolean
ini_ReadNodeFile
(
pwr_tStatus
*
,
ini_sContext
*
);
#endif
sev/exe/sev_ini/src/os_linux/hw_x86/makefile
0 → 100644
View file @
7a20e851
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
sev/exe/sev_ini/src/os_linux/link_rule.mk
0 → 100644
View file @
7a20e851
ifndef
link_rule_mk
link_rule_mk
:=
1
link
=
$(ldxx)
$(elinkflags)
$(domap)
-o
$(export_exe)
\
$(export_obj)
$(objects)
$(wb_msg_eobjs)
$(rt_msg_eobjs)
\
$(pwr_eobj)
/rt_io_user.o
\
-lpwr_sev
-lpwr_rt
-lpwr_co
$(linkmysql)
\
-lpwr_msg_dummy
\
-lrpcsvc
-lpthread
-lm
-lrt
-ldb_cxx
-lz
-lcrypt
#-lpwr_wb -lpwr_rt -lpwr_ge -lpwr_flow -lpwr_glow -lpwr_co \
# -L/usr/X11R6/lib -L/usr/local/BerkeleyDB.4.0/lib \
# -L/opt/gnome/lib \
# -lantlr -lImlib -lMrm -lXm -lXpm -lXt -lX11 -lXext -lXp\
# -lXmu -lSM -lICE\
endif
sev/exe/sev_ini/src/sev_ini.c
0 → 100644
View file @
7a20e851
/*
* Proview $Id: sev_ini.c,v 1.1 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <sys/wait.h>
#include <fcntl.h>
#include "co_ver.h"
#include "co_time.h"
#include "co_dcli.h"
#include "ini.h"
#include "rt_errl.h"
#include "rt_errh.h"
#include "rt_qini.h"
#include "rt_qcom.h"
#include "rt_ini_event.h"
#include "rt_ini_msg.h"
#include "rt_errh_msg.h"
#include "rt_pwr_msg.h"
extern
int
getopt
();
static
ini_sContext
*
createContext
(
int
argc
,
char
**
argv
);
static
int
checkErrors
(
ini_sContext
*
);
static
pwr_tStatus
events
(
ini_sContext
*
cp
);
static
pwr_tStatus
stop
(
int
argc
,
char
**
argv
,
ini_sContext
*
cp
);
static
pwr_tStatus
terminate
(
ini_sContext
*
cp
);
static
pwr_tStatus
start
(
ini_sContext
*
cp
);
static
void
usage
(
char
*
);
static
void
ini_errl_cb
(
void
*
userdata
,
char
*
str
,
char
severity
,
pwr_tStatus
sts
,
int
anix
,
int
message_type
);
int
main
(
int
argc
,
char
**
argv
)
{
ini_sContext
*
cp
;
pwr_tStatus
sts
;
cp
=
createContext
(
argc
,
argv
);
ver_WriteVersionInfo
(
"Proview/R Storage Environment"
);
if
(
cp
->
flags
.
b
.
stop
)
{
sts
=
stop
(
argc
,
argv
,
cp
);
}
else
{
sts
=
start
(
cp
);
sts
=
events
(
cp
);
errh_LogInfo
(
&
cp
->
log
,
"Ich sterbe!!"
);
}
exit
(
sts
);
}
static
pwr_tStatus
start
(
ini_sContext
*
cp
)
{
pwr_tStatus
sts
;
char
console
[
80
];
qini_sNode
*
nep
;
qcom_sAid
aid
;
int
fd
;
if
(
strcmp
(
cp
->
console
,
""
)
==
0
)
strcpy
(
console
,
"/dev/console"
);
else
strcpy
(
console
,
cp
->
console
);
if
((
fd
=
open
(
console
,
O_APPEND
|
O_WRONLY
))
==
-
1
)
errl_Init
(
NULL
,
ini_errl_cb
,
cp
);
else
{
close
(
fd
);
errl_Init
(
console
,
ini_errl_cb
,
cp
);
}
errh_Init
(
"pwr_ini"
,
errh_eAnix_ini
);
if
(
cp
->
flags
.
b
.
interactive
)
errh_Interactive
();
ini_CheckContext
(
&
sts
,
cp
);
ini_ReadBootFile
(
&
sts
,
cp
);
ini_ReadNodeFile
(
&
sts
,
cp
);
for
(
nep
=
tree_Minimum
(
&
sts
,
cp
->
nid_t
);
nep
!=
NULL
;
nep
=
tree_Successor
(
&
sts
,
cp
->
nid_t
,
nep
))
{
if
(
strcmp
(
cp
->
nodename
,
nep
->
name
)
==
0
)
{
cp
->
me
=
nep
;
break
;
}
}
if
(
cp
->
me
==
NULL
)
{
errh_LogFatal
(
&
cp
->
log
,
"Cannot find my own node in %s
\n
"
,
cp
->
nodefile
.
name
);
exit
(
QCOM__WEIRD
);
}
if
(
!
checkErrors
(
cp
))
exit
(
0
);
/* Logfile is always $pwrp_log/pwr.log from V4.0.0 and handled by Linux log rotation */
char
fname
[
256
];
sprintf
(
fname
,
"$pwrp_log/pwr_%s.log"
,
cp
->
nodename
);
dcli_translate_filename
(
fname
,
fname
);
errl_SetFile
(
fname
);
errh_LogInfo
(
&
cp
->
log
,
"Setting log file to: %s"
,
fname
);
// ini_SetSystemStatus( cp, PWR__STARTUP);
errh_SetStatus
(
PWR__STARTUP
);
qini_BuildDb
(
&
sts
,
cp
->
nid_t
,
cp
->
me
,
NULL
,
cp
->
busid
);
ini_ProcTable
(
&
sts
,
cp
);
ini_ProcIter
(
&
sts
,
cp
,
proc_mProcess_system
,
ini_ProcStart
);
ini_ProcIter
(
&
sts
,
cp
,
proc_mProcess_system
,
ini_ProcPrio
);
ini_ProcIter
(
&
sts
,
cp
,
proc_mProcess_user
,
ini_ProcStart
);
ini_ProcIter
(
&
sts
,
cp
,
proc_mProcess_user
,
ini_ProcPrio
);
qcom_Init
(
&
sts
,
&
aid
,
"pwr_sev_init"
);
if
(
EVEN
(
sts
))
{
errh_LogFatal
(
&
cp
->
log
,
"qcom_Init, %m"
,
sts
);
exit
(
sts
);
}
qcom_CreateQ
(
&
sts
,
&
cp
->
eventQ
,
NULL
,
"iniEvent"
);
if
(
EVEN
(
sts
))
{
errh_LogFatal
(
&
cp
->
log
,
"qcom_CreateQ, %m"
,
sts
);
exit
(
sts
);
}
// ini_SetSystemStatus( cp, PWR__RUNNING);
errh_SetStatus
(
PWR__SRUN
);
return
sts
;
}
static
pwr_tStatus
stop
(
int
argc
,
char
**
argv
,
ini_sContext
*
cp
)
{
pwr_tStatus
sts
;
qcom_sQid
qid
;
qcom_sPut
put
;
char
data
[]
=
"Shutdown you fool!"
;
if
(
!
qcom_Init
(
&
sts
,
0
,
"pwr_ini_stop"
))
{
exit
(
sts
);
}
qid
.
qix
=
550715
;
qid
.
nid
=
0
;
put
.
type
.
b
=
11
;
put
.
type
.
s
=
1
;
put
.
reply
.
qix
=
0
;
put
.
reply
.
nid
=
0
;
put
.
data
=
data
;
put
.
size
=
sizeof
(
data
)
+
1
;
qcom_Put
(
&
sts
,
&
qid
,
&
put
);
return
0
;
}
static
pwr_tStatus
terminate
(
ini_sContext
*
cp
)
{
pwr_tStatus
sts
;
qcom_SignalAnd
(
&
sts
,
&
qcom_cQini
,
0
);
qcom_SignalOr
(
&
sts
,
&
qcom_cQini
,
ini_mEvent_terminate
);
qcom_Exit
(
NULL
);
/* Now sleep for a while */
sleep
(
3
);
/* Unlink shared memory and semaphores */
qdb_UnlinkDb
();
/* Unlink errlog mwessage queue */
errl_Unlink
();
exit
(
1
);
}
static
int
ask_yes_no
(
ini_sContext
*
cp
,
char
*
text
)
{
printf
(
"%s ? (y|n) [n]: "
,
text
);
printf
(
"n
\n
"
);
return
0
;
}
static
int
checkErrors
(
ini_sContext
*
cp
)
{
if
(
cp
->
warnings
==
0
&&
cp
->
errors
==
0
&&
cp
->
fatals
==
0
)
return
1
;
if
(
cp
->
fatals
>
0
)
{
errh_LogFatal
(
&
cp
->
log
,
"Found %d warning(s), %d error(s) and %d fatal error(s)"
,
cp
->
warnings
,
cp
->
errors
,
cp
->
fatals
);
if
(
cp
->
flags
.
b
.
ignoreFatal
)
{
errh_LogInfo
(
&
cp
->
log
,
"Ignoring fatal errors, errors and warnings, continued..."
);
return
1
;
}
else
{
return
ask_yes_no
(
cp
,
"Do you want to continue"
);
}
}
if
(
cp
->
errors
>
0
)
{
errh_LogError
(
&
cp
->
log
,
"Found %d warning(s), %d error(s) and %d fatal error(s)"
,
cp
->
warnings
,
cp
->
errors
,
cp
->
fatals
);
if
(
cp
->
flags
.
b
.
ignoreError
)
{
errh_LogInfo
(
&
cp
->
log
,
"Ignoring errors and warnings, continued..."
);
return
1
;
}
else
{
return
ask_yes_no
(
cp
,
"Do you want to continue"
);
}
}
if
(
cp
->
warnings
>
0
)
{
errh_LogWarning
(
&
cp
->
log
,
"Found %d warning(s), %d error(s) and %d fatal error(s)"
,
cp
->
warnings
,
cp
->
errors
,
cp
->
fatals
);
if
(
cp
->
flags
.
b
.
ignoreWarning
)
{
errh_LogInfo
(
&
cp
->
log
,
"Ignoring warnings, continued..."
);
return
1
;
}
else
{
return
ask_yes_no
(
cp
,
"Do you want to continue"
);
}
}
return
1
;
}
static
ini_sContext
*
createContext
(
int
argc
,
char
**
argv
)
{
int
c
;
extern
char
*
optarg
;
extern
int
optind
;
#if 1
extern
int
optind
;
#endif
ini_sContext
*
cp
;
pwr_tStatus
sts
;
#if defined(OS_LYNX) || defined(OS_LINUX)
char
*
options
=
"a:b:c:d:efg:hin:p:q:rsu:vwA:H:V"
;
#else
char
*
options
=
"a:b:d:efhin:p:q:rvwA:H:V"
;
#endif
#if 0
extern int opterr;
opterr = 0;
#endif
optind
=
0
;
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"--version"
)
==
0
)
{
system
(
"cat $pwr_exe/rt_version.dat"
);
exit
(
1
);
}
if
(
!
(
cp
=
ini_CreateContext
(
&
sts
)))
{
fprintf
(
stderr
,
"%s: could not allocate context
\n
"
,
argv
[
0
]);
exit
(
1
);
}
while
((
c
=
getopt
(
argc
,
argv
,
options
))
!=
-
1
)
{
switch
(
c
)
{
case
'a'
:
cp
->
flags
.
b
.
applfile
=
1
;
strcpy
(
cp
->
applfile
.
name
,
optarg
);
break
;
case
'c'
:
strcpy
(
cp
->
console
,
optarg
);
break
;
case
'd'
:
strcpy
(
cp
->
dir
,
optarg
);
break
;
case
'e'
:
cp
->
flags
.
b
.
ignoreError
=
1
;
break
;
case
'f'
:
cp
->
flags
.
b
.
ignoreFatal
=
1
;
break
;
case
'h'
:
cp
->
flags
.
b
.
hostname
=
1
;
strcpy
(
cp
->
hostname
,
optarg
);
break
;
case
'i'
:
cp
->
flags
.
b
.
interactive
=
1
;
break
;
case
'n'
:
cp
->
flags
.
b
.
nodename
=
1
;
strcpy
(
cp
->
nodename
,
optarg
);
break
;
case
'q'
:
cp
->
flags
.
b
.
busid
=
1
;
cp
->
busid
=
atoi
(
optarg
);
break
;
case
'r'
:
cp
->
flags
.
b
.
restart
=
1
;
cp
->
flags
.
b
.
interactive
=
1
;
break
;
case
's'
:
cp
->
flags
.
b
.
stop
=
1
;
break
;
case
'v'
:
cp
->
flags
.
b
.
verbose
=
1
;
break
;
case
'w'
:
cp
->
flags
.
b
.
ignoreWarning
=
1
;
break
;
case
'A'
:
cp
->
flags
.
b
.
aliasfile
=
1
;
strcpy
(
cp
->
aliasfile
.
name
,
optarg
);
break
;
case
'?'
:
usage
(
argv
[
0
]);
break
;
}
}
return
cp
;
}
static
void
usage
(
char
*
name
)
{
#if defined(OS_LYNX) || defined(OS_LINUX)
fprintf
(
stderr
,
"usage: %s -a arg -b arg -d arg -efg arg -hip arg -q arg -ru arg -s arg -vwA arg -H arg
\n
"
,
name
);
#else
fprintf
(
stderr
,
"usage: %s -a arg -b arg -d arg -efhip arg -q arg -rvwA arg -H arg
\n
"
,
name
);
#endif
fprintf
(
stderr
,
" -? : give help
\n
"
);
fprintf
(
stderr
,
" -a arg: use 'arg' as application file
\n
"
);
fprintf
(
stderr
,
" -b arg: use 'arg' as boot file
\n
"
);
fprintf
(
stderr
,
" -d arg: use files from directory 'arg'
\n
"
);
fprintf
(
stderr
,
" -e : ignore errors
\n
"
);
fprintf
(
stderr
,
" -f : ignore fatal errors
\n
"
);
#if defined(OS_LYNX) || defined(OS_LINUX)
fprintf
(
stderr
,
" -g arg: setgid to 'arg' before starting
\n
"
);
#endif
fprintf
(
stderr
,
" -h : give help
\n
"
);
fprintf
(
stderr
,
" -i : interactive, log to stdout
\n
"
);
fprintf
(
stderr
,
" -p arg: use 'arg' as PLC
\n
"
);
fprintf
(
stderr
,
" -q arg: use 'arg' as qcom bus id
\n
"
);
fprintf
(
stderr
,
" -r : restart with new versions of loadfiles and PLC
\n
"
);
#if defined(OS_LYNX) || defined(OS_LINUX)
fprintf
(
stderr
,
" -s : stop of Proview/R
\n
"
);
fprintf
(
stderr
,
" -u arg: setuid to 'arg' before starting
\n
"
);
#endif
fprintf
(
stderr
,
" -v : verbose
\n
"
);
fprintf
(
stderr
,
" -w : ignore warnings
\n
"
);
fprintf
(
stderr
,
" -A arg: use 'arg' as alias file
\n
"
);
fprintf
(
stderr
,
" -H arg: use 'arg' as hostname
\n
"
);
fprintf
(
stderr
,
" -N arg: use 'arg' as nodename
\n
"
);
exit
(
1
);
}
static
pwr_tStatus
events
(
ini_sContext
*
cp
)
{
pwr_tStatus
sts
=
INI__SUCCESS
;
qcom_sGet
get
;
#if defined(OS_LYNX) || defined(OS_LINUX)
int
tmo_ms
=
1000
;
#else
int
tmo_ms
=
qcom_cTmoEternal
;
#endif
cp
->
myQ
.
qix
=
550715
;
cp
->
myQ
.
nid
=
0
;
qcom_CreateQ
(
&
sts
,
&
cp
->
myQ
,
NULL
,
"events"
);
if
(
EVEN
(
sts
))
{
errh_LogFatal
(
&
cp
->
log
,
"qcom_CreateQ, %m"
,
sts
);
exit
(
sts
);
}
for
(;;)
{
get
.
data
=
NULL
;
qcom_Get
(
&
sts
,
&
cp
->
myQ
,
&
get
,
tmo_ms
);
/* Request for termination ?? */
if
(
sts
!=
QCOM__TMO
&&
sts
!=
QCOM__QEMPTY
&&
get
.
type
.
b
==
11
)
{
sts
=
terminate
(
cp
);
return
sts
;
}
}
return
INI__SUCCESS
;
}
static
void
ini_errl_cb
(
void
*
userdata
,
char
*
str
,
char
severity
,
pwr_tStatus
sts
,
int
anix
,
int
message_type
)
{
}
sev/exe/sev_server/src/sev_server.cpp
View file @
7a20e851
/*
/*
* Proview $Id: sev_server.cpp,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: sev_server.cpp,v 1.
2 2008-09-05 08:38:58
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
...
@@ -22,8 +22,10 @@
...
@@ -22,8 +22,10 @@
#include "co_dcli.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_time.h"
#include "co_error.h"
#include "co_error.h"
#include "co_cnf.h"
#include "rt_qcom.h"
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
#include "sev_server.h"
#include "sev_server.h"
#include "rt_sev_net.h"
#include "rt_sev_net.h"
#include "sev_dbms.h"
#include "sev_dbms.h"
...
@@ -37,6 +39,7 @@ int sev_server::init()
...
@@ -37,6 +39,7 @@ int sev_server::init()
pwr_tNid
nid
;
pwr_tNid
nid
;
pwr_tStatus
sts
;
pwr_tStatus
sts
;
qcom_sAid
aid
;
qcom_sAid
aid
;
qcom_sQid
qini
;
m_db
->
get_items
(
&
m_sts
);
m_db
->
get_items
(
&
m_sts
);
...
@@ -61,15 +64,18 @@ int sev_server::init()
...
@@ -61,15 +64,18 @@ int sev_server::init()
if
(
sts
==
QCOM__QALLREXIST
)
{
if
(
sts
==
QCOM__QALLREXIST
)
{
if
(
!
qcom_AttachQ
(
&
sts
,
&
qid
))
{
if
(
!
qcom_AttachQ
(
&
sts
,
&
qid
))
{
if
(
!
qcom_DeleteQ
(
&
sts
,
&
qid
))
if
(
!
qcom_DeleteQ
(
&
sts
,
&
qid
))
co_error
(
sts
);
throw
co_error
(
sts
);
if
(
!
qcom_CreateQ
(
&
sts
,
&
qid
,
&
attr
,
"SevServer"
))
if
(
!
qcom_CreateQ
(
&
sts
,
&
qid
,
&
attr
,
"SevServer"
))
co_error
(
sts
);
throw
co_error
(
sts
);
}
}
}
}
else
else
throw
co_error
(
sts
);
throw
co_error
(
sts
);
}
}
qini
=
qcom_cQini
;
if
(
!
qcom_Bind
(
&
sts
,
&
qid
,
&
qini
))
throw
co_error
(
sts
);
// Get all qcom nodes
// Get all qcom nodes
qcom_MyNode
(
&
m_sts
,
&
node
);
qcom_MyNode
(
&
m_sts
,
&
node
);
...
@@ -160,7 +166,12 @@ int sev_server::send_itemlist( qcom_sQid tgt)
...
@@ -160,7 +166,12 @@ int sev_server::send_itemlist( qcom_sQid tgt)
pwr_tStatus
sts
,
lsts
;
pwr_tStatus
sts
,
lsts
;
int
size
;
int
size
;
item_cnt
=
m_db
->
m_items
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
if
(
m_db
->
m_items
[
i
].
deleted
)
continue
;
item_cnt
++
;
}
if
(
!
item_cnt
)
if
(
!
item_cnt
)
return
1
;
return
1
;
...
@@ -171,19 +182,23 @@ int sev_server::send_itemlist( qcom_sQid tgt)
...
@@ -171,19 +182,23 @@ int sev_server::send_itemlist( qcom_sQid tgt)
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Type
=
sev_eMsgType_HistItems
;
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Type
=
sev_eMsgType_HistItems
;
int
idx
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
oid
=
m_db
->
m_items
[
i
].
oid
;
if
(
m_db
->
m_items
[
i
].
deleted
)
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
oname
,
m_db
->
m_items
[
i
].
oname
);
continue
;
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
aname
,
m_db
->
m_items
[
i
].
aname
);
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
oid
=
m_db
->
m_items
[
i
].
oid
;
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
storagetime
=
m_db
->
m_items
[
i
].
storagetime
;
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
oname
,
m_db
->
m_items
[
i
].
oname
);
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
type
=
m_db
->
m_items
[
i
].
vtype
;
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
aname
,
m_db
->
m_items
[
i
].
aname
);
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
size
=
m_db
->
m_items
[
i
].
vsize
;
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
storagetime
=
m_db
->
m_items
[
i
].
storagetime
;
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
description
,
m_db
->
m_items
[
i
].
description
);
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
type
=
m_db
->
m_items
[
i
].
vtype
;
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
unit
,
m_db
->
m_items
[
i
].
unit
);
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
size
=
m_db
->
m_items
[
i
].
vsize
;
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
i
].
scantime
=
m_db
->
m_items
[
i
].
scantime
;
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
description
,
m_db
->
m_items
[
i
].
description
);
strcpy
(
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
unit
,
m_db
->
m_items
[
i
].
unit
);
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Items
[
idx
].
scantime
=
m_db
->
m_items
[
i
].
scantime
;
idx
++
;
}
}
if
(
m_db
->
m_items
.
size
()
==
0
)
if
(
!
item_cnt
)
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Status
=
SEV__NOITEMS
;
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Status
=
SEV__NOITEMS
;
else
else
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Status
=
SEV__SUCCESS
;
((
sev_sMsgHistItems
*
)
put
.
data
)
->
Status
=
SEV__SUCCESS
;
...
@@ -201,6 +216,35 @@ int sev_server::send_itemlist( qcom_sQid tgt)
...
@@ -201,6 +216,35 @@ int sev_server::send_itemlist( qcom_sQid tgt)
return
1
;
return
1
;
}
}
int
sev_server
::
delete_item
(
qcom_sQid
tgt
,
sev_sMsgHistItemDelete
*
rmsg
)
{
qcom_sPut
put
;
pwr_tStatus
sts
,
lsts
;
put
.
size
=
sizeof
(
sev_sMsgHistItemStatus
);
put
.
data
=
qcom_Alloc
(
&
lsts
,
put
.
size
);
m_db
->
delete_item
(
&
sts
,
rmsg
->
Oid
,
rmsg
->
AName
);
((
sev_sMsgHistItemStatus
*
)
put
.
data
)
->
Type
=
sev_eMsgType_HistItemStatus
;
((
sev_sMsgHistItemStatus
*
)
put
.
data
)
->
Oid
=
rmsg
->
Oid
;
strcpy
(
((
sev_sMsgHistItemStatus
*
)
put
.
data
)
->
AName
,
rmsg
->
AName
);
((
sev_sMsgHistItemStatus
*
)
put
.
data
)
->
Status
=
sts
;
put
.
reply
.
nid
=
m_nodes
[
0
].
nid
;
put
.
reply
.
qix
=
sev_eProcSevServer
;
put
.
type
.
b
=
(
qcom_eBtype
)
sev_cMsgClass
;
put
.
type
.
s
=
(
qcom_eStype
)
sev_eMsgType_HistItemStatus
;
put
.
msg_id
=
m_msg_id
++
;
if
(
!
qcom_Put
(
&
sts
,
&
tgt
,
&
put
))
{
qcom_Free
(
&
sts
,
put
.
data
);
return
0
;
}
return
1
;
}
int
sev_server
::
mainloop
()
int
sev_server
::
mainloop
()
{
{
qcom_sQid
qid
;
qcom_sQid
qid
;
...
@@ -250,9 +294,21 @@ int sev_server::mainloop()
...
@@ -250,9 +294,21 @@ int sev_server::mainloop()
case
sev_eMsgType_HistItemsRequest
:
case
sev_eMsgType_HistItemsRequest
:
send_itemlist
(
get
.
reply
);
send_itemlist
(
get
.
reply
);
break
;
break
;
case
sev_eMsgType_HistItemDelete
:
delete_item
(
get
.
reply
,
(
sev_sMsgHistItemDelete
*
)
mp
);
break
;
default:
;
default:
;
}
}
break
;
break
;
case
qcom_eBtype_event
:
{
ini_mEvent
new_event
;
qcom_sEvent
*
ep
=
(
qcom_sEvent
*
)
get
.
data
;
new_event
.
m
=
ep
->
mask
;
if
(
new_event
.
b
.
terminate
)
exit
(
0
);
break
;
}
default:
;
default:
;
}
}
...
@@ -392,6 +448,8 @@ void sev_server::garbage_collector()
...
@@ -392,6 +448,8 @@ void sev_server::garbage_collector()
clock_gettime
(
CLOCK_REALTIME
,
&
currenttime
);
clock_gettime
(
CLOCK_REALTIME
,
&
currenttime
);
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_db
->
m_items
.
size
();
i
++
)
{
if
(
m_db
->
m_items
[
i
].
deleted
)
continue
;
if
(
m_db
->
m_items
[
i
].
storagetime
.
tv_sec
==
0
)
if
(
m_db
->
m_items
[
i
].
storagetime
.
tv_sec
==
0
)
continue
;
continue
;
...
@@ -407,6 +465,7 @@ int main()
...
@@ -407,6 +465,7 @@ int main()
sev_dbms_env
*
env
;
sev_dbms_env
*
env
;
pwr_tFileName
envname
;
pwr_tFileName
envname
;
char
socket
[
200
];
sprintf
(
envname
,
"$pwrp_db/%s.db"
,
sev_dbms_env
::
dbName
());
sprintf
(
envname
,
"$pwrp_db/%s.db"
,
sev_dbms_env
::
dbName
());
dcli_translate_filename
(
envname
,
envname
);
dcli_translate_filename
(
envname
,
envname
);
...
@@ -414,8 +473,9 @@ int main()
...
@@ -414,8 +473,9 @@ int main()
env
=
new
sev_dbms_env
(
envname
);
env
=
new
sev_dbms_env
(
envname
);
env
->
open
(
envname
);
env
->
open
(
envname
);
if
(
!
env
->
exists
())
{
if
(
!
env
->
exists
())
{
env
->
create
(
envname
,
"aristotle"
,
"pwrp"
,
""
,
sev_dbms_env
::
dbName
(),
50
,
cnf_get_value
(
"mysqlSocket"
,
socket
);
"/var/run/mysqld/mysqld.sock"
);
env
->
create
(
envname
,
"localhost"
,
"pwrp"
,
""
,
sev_dbms_env
::
dbName
(),
50
,
socket
);
env
->
open
(
envname
);
env
->
open
(
envname
);
...
...
sev/exe/sev_server/src/sev_server.h
View file @
7a20e851
/*
/*
* Proview $Id: sev_server.h,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: sev_server.h,v 1.
2 2008-09-05 08:38:58
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
...
@@ -88,6 +88,7 @@ class sev_server {
...
@@ -88,6 +88,7 @@ class sev_server {
int
receive_histdata
(
sev_sMsgHistDataStore
*
msg
,
unsigned
int
size
);
int
receive_histdata
(
sev_sMsgHistDataStore
*
msg
,
unsigned
int
size
);
int
send_histdata
(
qcom_sQid
tgt
,
sev_sMsgHistDataGetRequest
*
msg
,
unsigned
int
size
);
int
send_histdata
(
qcom_sQid
tgt
,
sev_sMsgHistDataGetRequest
*
msg
,
unsigned
int
size
);
int
send_itemlist
(
qcom_sQid
tgt
);
int
send_itemlist
(
qcom_sQid
tgt
);
int
delete_item
(
qcom_sQid
tgt
,
sev_sMsgHistItemDelete
*
rmsg
);
void
garbage_collector
();
void
garbage_collector
();
};
};
#endif
#endif
sev/exe/sev_xtt/gtk/os_linux/link_rule.mk
View file @
7a20e851
...
@@ -4,7 +4,7 @@ link_rule_mk := 1
...
@@ -4,7 +4,7 @@ link_rule_mk := 1
link
=
$(ldxx)
$(elinkflags)
$(domap)
-o
$(pwr_exe)
/sev_xtt_gtk
\
link
=
$(ldxx)
$(elinkflags)
$(domap)
-o
$(pwr_exe)
/sev_xtt_gtk
\
$(bld_dir)
/sev_xtt_gtk.o
\
$(bld_dir)
/sev_xtt_gtk.o
\
$(bld_dir)
/xtt_tbl_gtk.o
$(bld_dir)
/xtt_tblnav_gtk.o
$(bld_dir)
/xtt_tbl.o
\
$(bld_dir)
/xtt_tbl_gtk.o
$(bld_dir)
/xtt_tblnav_gtk.o
$(bld_dir)
/xtt_tbl.o
\
$(bld_dir)
/xtt_tblnav.o
\
$(bld_dir)
/xtt_tblnav.o
$(bld_dir)
/xtt_tbl_command.o
\
$(rt_msg_eobjs)
\
$(rt_msg_eobjs)
\
$(pwr_eobj)
/rt_io_user.o
-L
/usr/X11R6/lib
\
$(pwr_eobj)
/rt_io_user.o
-L
/usr/X11R6/lib
\
-L
/opt/gnome/lib
\
-L
/opt/gnome/lib
\
...
...
sev/exe/sev_xtt/gtk/sev_xtt_gtk.cpp
View file @
7a20e851
/*
/*
* Proview $Id: sev_xtt_gtk.cpp,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: sev_xtt_gtk.cpp,v 1.
2 2008-09-05 08:38:58
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
...
@@ -18,15 +18,25 @@
...
@@ -18,15 +18,25 @@
*/
*/
#include <fstream.h>
#include <vector.h>
#include <gtk/gtk.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr.h"
#include "pwr_class.h"
#include "pwr_class.h"
#include "xtt_tbl_gtk.h"
#include "co_error.h"
#include "co_error.h"
#include "rt_qcom.h"
#include "rt_qcom.h"
#include "rt_errh.h"
#include "rt_errh.h"
#include "rt_sevcli.h"
#include "rt_sevcli.h"
#include "xtt_tbl_gtk.h"
void
tbl_close_cb
(
void
*
tbl
)
{
XttTblGtk
*
xtttbl
=
(
XttTblGtk
*
)
tbl
;
delete
xtttbl
;
exit
(
0
);
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
...
@@ -49,17 +59,24 @@ int main( int argc, char *argv[])
...
@@ -49,17 +59,24 @@ int main( int argc, char *argv[])
if
(
EVEN
(
sts
))
co_error
(
sts
);
if
(
EVEN
(
sts
))
co_error
(
sts
);
sevcli_init
(
&
sts
,
&
sevcli
);
sevcli_init
(
&
sts
,
&
sevcli
);
if
(
EVEN
(
sts
))
co_error
(
sts
);
if
(
EVEN
(
sts
))
{
printf
(
"Sev client init error %u
\n
"
,
sts
);
exit
(
0
);
}
if
(
strcmp
(
servername
,
""
)
!=
0
)
if
(
strcmp
(
servername
,
""
)
!=
0
)
sevcli_set_servernode
(
&
sts
,
sevcli
,
servername
);
sevcli_set_servernode
(
&
sts
,
sevcli
,
servername
);
sevcli_get_itemlist
(
&
sts
,
sevcli
,
&
items
,
&
itemcnt
);
sevcli_get_itemlist
(
&
sts
,
sevcli
,
&
items
,
&
itemcnt
);
if
(
EVEN
(
sts
))
co_error
(
sts
);
if
(
EVEN
(
sts
))
{
printf
(
"Sev client get itemlist error %u
\n
"
,
sts
);
exit
(
0
);
}
gtk_init
(
&
argc
,
&
argv
);
gtk_init
(
&
argc
,
&
argv
);
new
XttTblGtk
(
0
,
0
,
sevcli
,
items
,
itemcnt
);
XttTblGtk
*
tbl
=
new
XttTblGtk
(
0
,
0
,
sevcli
,
items
,
itemcnt
);
tbl
->
close_cb
=
tbl_close_cb
;
gtk_main
();
gtk_main
();
return
1
;
return
1
;
...
...
sev/exe/sev_xtt/gtk/xtt_tbl_gtk.cpp
View file @
7a20e851
/*
/*
* Proview $Id: xtt_tbl_gtk.cpp,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: xtt_tbl_gtk.cpp,v 1.
2 2008-09-05 08:38:58
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
...
@@ -19,11 +19,17 @@
...
@@ -19,11 +19,17 @@
/* xtt_tbl.cpp -- Sev Table Viewer */
/* xtt_tbl.cpp -- Sev Table Viewer */
#include <fstream.h>
#include <vector.h>
#include "glow_std.h"
#include "glow_std.h"
#include "co_cdh.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_wow_gtk.h"
#include "co_wow_gtk.h"
#include "co_xhelp_gtk.h"
#include "co_login_gtk.h"
#include "flow.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browctx.h"
...
@@ -48,7 +54,10 @@ static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
...
@@ -48,7 +54,10 @@ static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
{
XttTblGtk
*
xtttbl
=
(
XttTblGtk
*
)
data
;
XttTblGtk
*
xtttbl
=
(
XttTblGtk
*
)
data
;
delete
xtttbl
;
if
(
xtttbl
->
close_cb
)
(
xtttbl
->
close_cb
)(
xtttbl
);
else
delete
xtttbl
;
return
FALSE
;
return
FALSE
;
}
}
...
@@ -69,20 +78,128 @@ static gboolean xtttbl_focus_in_event( GtkWidget *w, GdkEvent *event, gpointer d
...
@@ -69,20 +78,128 @@ static gboolean xtttbl_focus_in_event( GtkWidget *w, GdkEvent *event, gpointer d
return
FALSE
;
return
FALSE
;
}
}
static
void
xtttbl_activate_close
(
GtkWidget
*
w
,
gpointer
data
)
void
XttTblGtk
::
activate_print
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
activate_print
();
}
void
XttTblGtk
::
activate_login
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
xtt
->
open_login
();
}
void
XttTblGtk
::
activate_logout
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
xtt
->
logout
();
}
void
XttTblGtk
::
activate_close
(
GtkWidget
*
w
,
gpointer
data
)
{
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
data
;
XttTbl
*
xtttbl
=
(
XttTbl
*
)
data
;
if
(
xtttbl
->
close_cb
)
(
xtttbl
->
close_cb
)(
xtttbl
);
else
delete
xtttbl
;
}
void
XttTblGtk
::
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
xtt
->
activate_zoom_in
();
}
void
XttTblGtk
::
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
xtt
->
activate_zoom_out
();
}
void
XttTblGtk
::
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
xtt
->
activate_zoom_reset
();
}
void
XttTblGtk
::
activate_help
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
activate_help
();
}
void
XttTblGtk
::
activate_help_project
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
activate_help_project
();
}
void
XttTblGtk
::
activate_help_proview
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
delete
xtttbl
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
activate_help_proview
();
}
}
static
void
xtttbl_activate_help
(
GtkWidget
*
w
,
gpointer
data
)
void
XttTblGtk
::
activate_opendshist
(
GtkWidget
*
w
,
gpointer
data
)
{
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
activate_opendshist
();
}
}
static
void
xtttbl_activate_opendshist
(
GtkWidget
*
w
,
gpointer
data
)
void
XttTblGtk
::
activate_delete_item
(
GtkWidget
*
w
,
gpointer
data
)
{
{
((
XttTbl
*
)
data
)
->
activate_opendshist
();
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
(
pwr_mPrv_SevAdmin
))
return
;
xtt
->
activate_delete_item
();
}
void
XttTblGtk
::
activate_tree_layout
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
tblnav
->
show_tree
();
}
void
XttTblGtk
::
activate_list_layout
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
xtt
->
tblnav
->
show_list
();
}
}
XttDsHist
*
XttTblGtk
::
dshist_new
(
pwr_tOid
oid
,
char
*
aname
)
XttDsHist
*
XttTblGtk
::
dshist_new
(
pwr_tOid
oid
,
char
*
aname
)
...
@@ -100,6 +217,72 @@ XttDsHist *XttTblGtk::dshist_new( pwr_tOid oid, char *aname)
...
@@ -100,6 +217,72 @@ XttDsHist *XttTblGtk::dshist_new( pwr_tOid oid, char *aname)
sevcli
,
&
sts
);
sevcli
,
&
sts
);
}
}
CoLogin
*
XttTblGtk
::
login_new
(
char
*
name
,
char
*
groupname
,
void
(
*
bc_success
)(
void
*
),
void
(
*
bc_cancel
)(
void
*
),
pwr_tStatus
*
status
)
{
return
new
CoLoginGtk
(
this
,
toplevel
,
name
,
groupname
,
bc_success
,
bc_cancel
,
status
);
}
void
XttTblGtk
::
activate_command
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
if
(
!
xtt
->
is_authorized
())
return
;
if
(
xtt
->
command_open
)
{
g_object_set
(
((
XttTblGtk
*
)
xtt
)
->
cmd_input
,
"visible"
,
FALSE
,
NULL
);
xtt
->
set_prompt
(
""
);
xtt
->
command_open
=
0
;
return
;
}
gtk_editable_delete_text
(
GTK_EDITABLE
(((
XttTblGtk
*
)
xtt
)
->
cmd_input
),
0
,
-
1
);
g_object_set
(
((
XttTblGtk
*
)
xtt
)
->
cmd_input
,
"visible"
,
TRUE
,
NULL
);
xtt
->
message
(
' '
,
""
);
gtk_widget_grab_focus
(
((
XttTblGtk
*
)
xtt
)
->
cmd_input
);
xtt
->
set_prompt
(
"xtt >"
);
xtt
->
command_open
=
1
;
}
void
XttTblGtk
::
set_prompt
(
char
*
prompt
)
{
if
(
strcmp
(
prompt
,
""
)
==
0
)
{
g_object_set
(
cmd_prompt
,
"visible"
,
FALSE
,
NULL
);
g_object_set
(
msg_label
,
"visible"
,
TRUE
,
NULL
);
}
else
{
char
*
promptutf8
=
g_convert
(
prompt
,
-
1
,
"UTF-8"
,
"ISO8859-1"
,
NULL
,
NULL
,
NULL
);
g_object_set
(
msg_label
,
"visible"
,
FALSE
,
NULL
);
g_object_set
(
cmd_prompt
,
"visible"
,
TRUE
,
"label"
,
promptutf8
,
NULL
);
g_free
(
promptutf8
);
}
}
void
XttTblGtk
::
valchanged_cmd_input
(
GtkWidget
*
w
,
gpointer
data
)
{
XttTbl
*
xtt
=
(
XttTbl
*
)
data
;
int
sts
;
char
*
text
,
*
textutf8
;
textutf8
=
gtk_editable_get_chars
(
GTK_EDITABLE
(
w
),
0
,
-
1
);
text
=
g_convert
(
textutf8
,
-
1
,
"ISO8859-1"
,
"UTF-8"
,
NULL
,
NULL
,
NULL
);
g_free
(
textutf8
);
sts
=
xtt
->
command
(
text
);
g_object_set
(
w
,
"visible"
,
FALSE
,
NULL
);
xtt
->
set_prompt
(
""
);
xtt
->
command_open
=
0
;
xtt
->
tblnav
->
set_inputfocus
();
}
XttTblGtk
::
XttTblGtk
(
GtkWidget
*
a_parent_wid
,
XttTblGtk
::
XttTblGtk
(
GtkWidget
*
a_parent_wid
,
void
*
a_parent_ctx
,
void
*
a_parent_ctx
,
sevcli_tCtx
a_sevcli
,
sevcli_tCtx
a_sevcli
,
...
@@ -109,11 +292,12 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
...
@@ -109,11 +292,12 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
parent_wid
(
a_parent_wid
)
parent_wid
(
a_parent_wid
)
{
{
int
sts
;
int
sts
;
pwr_tFileName
fname
;
toplevel
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_WINDOW
,
toplevel
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_WINDOW
,
"default-height"
,
700
,
"default-height"
,
700
,
"default-width"
,
500
,
"default-width"
,
500
,
"title"
,
"
Object Attributes
"
,
"title"
,
"
SevXtt Navigator
"
,
NULL
);
NULL
);
g_signal_connect
(
toplevel
,
"delete_event"
,
G_CALLBACK
(
delete_event
),
this
);
g_signal_connect
(
toplevel
,
"delete_event"
,
G_CALLBACK
(
delete_event
),
this
);
...
@@ -132,10 +316,26 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
...
@@ -132,10 +316,26 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
GtkMenuBar
*
menu_bar
=
(
GtkMenuBar
*
)
g_object_new
(
GTK_TYPE_MENU_BAR
,
NULL
);
GtkMenuBar
*
menu_bar
=
(
GtkMenuBar
*
)
g_object_new
(
GTK_TYPE_MENU_BAR
,
NULL
);
// File entry
// File entry
GtkWidget
*
file_print
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Print"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
file_print
),
gtk_image_new_from_stock
(
"gtk-print"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
file_print
,
"activate"
,
G_CALLBACK
(
activate_print
),
this
);
GtkWidget
*
file_login
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Login"
));
g_signal_connect
(
file_login
,
"activate"
,
G_CALLBACK
(
activate_login
),
this
);
GtkWidget
*
file_logout
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Log_Out"
));
g_signal_connect
(
file_logout
,
"activate"
,
G_CALLBACK
(
activate_logout
),
this
);
GtkWidget
*
file_close
=
gtk_image_menu_item_new_from_stock
(
GTK_STOCK_CLOSE
,
accel_g
);
GtkWidget
*
file_close
=
gtk_image_menu_item_new_from_stock
(
GTK_STOCK_CLOSE
,
accel_g
);
g_signal_connect
(
file_close
,
"activate"
,
G_CALLBACK
(
xtttbl_
activate_close
),
this
);
g_signal_connect
(
file_close
,
"activate"
,
G_CALLBACK
(
activate_close
),
this
);
GtkMenu
*
file_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
GtkMenu
*
file_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_print
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_login
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_logout
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_close
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_close
);
GtkWidget
*
file
=
gtk_menu_item_new_with_mnemonic
(
"_File"
);
GtkWidget
*
file
=
gtk_menu_item_new_with_mnemonic
(
"_File"
);
...
@@ -145,55 +345,182 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
...
@@ -145,55 +345,182 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
// Functions entry
// Functions entry
GtkWidget
*
functions_opendshist
=
gtk_menu_item_new_with_mnemonic
(
"_Open DsHist"
);
GtkWidget
*
functions_opendshist
=
gtk_menu_item_new_with_mnemonic
(
"_Open DsHist"
);
g_signal_connect
(
functions_opendshist
,
"activate"
,
G_CALLBACK
(
xtttbl_activate_opendshist
),
this
);
g_signal_connect
(
functions_opendshist
,
"activate"
,
G_CALLBACK
(
activate_opendshist
),
this
);
GtkWidget
*
functions_command
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Co_mmand"
));
g_signal_connect
(
functions_command
,
"activate"
,
G_CALLBACK
(
activate_command
),
this
);
gtk_widget_add_accelerator
(
functions_command
,
"activate"
,
accel_g
,
'b'
,
GdkModifierType
(
GDK_CONTROL_MASK
),
GTK_ACCEL_VISIBLE
);
GtkWidget
*
functions_delete_item
=
gtk_menu_item_new_with_mnemonic
(
"_Delete Item"
);
g_signal_connect
(
functions_delete_item
,
"activate"
,
G_CALLBACK
(
activate_delete_item
),
this
);
GtkMenu
*
functions_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
GtkMenu
*
functions_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_opendshist
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_opendshist
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_command
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_delete_item
);
GtkWidget
*
functions
=
gtk_menu_item_new_with_mnemonic
(
"_Functions"
);
GtkWidget
*
functions
=
gtk_menu_item_new_with_mnemonic
(
"_Functions"
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
functions
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
functions
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
functions
),
GTK_WIDGET
(
functions_menu
));
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
functions
),
GTK_WIDGET
(
functions_menu
));
// View menu
GtkWidget
*
view_tree_layout
=
gtk_menu_item_new_with_mnemonic
(
"_Tree Layout"
);
g_signal_connect
(
view_tree_layout
,
"activate"
,
G_CALLBACK
(
activate_tree_layout
),
this
);
GtkWidget
*
view_list_layout
=
gtk_menu_item_new_with_mnemonic
(
"_List Layout"
);
g_signal_connect
(
view_list_layout
,
"activate"
,
G_CALLBACK
(
activate_list_layout
),
this
);
GtkWidget
*
view_zoom_in
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _In"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_in
),
gtk_image_new_from_stock
(
"gtk-zoom-in"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_in
,
"activate"
,
G_CALLBACK
(
activate_zoom_in
),
this
);
gtk_widget_add_accelerator
(
view_zoom_in
,
"activate"
,
accel_g
,
'i'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
view_zoom_out
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _Out"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_out
),
gtk_image_new_from_stock
(
"gtk-zoom-out"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_out
,
"activate"
,
G_CALLBACK
(
activate_zoom_out
),
this
);
gtk_widget_add_accelerator
(
view_zoom_out
,
"activate"
,
accel_g
,
'o'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
view_zoom_reset
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _Reset"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_reset
),
gtk_image_new_from_stock
(
"gtk-zoom-100"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_reset
,
"activate"
,
G_CALLBACK
(
activate_zoom_reset
),
this
);
GtkMenu
*
view_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_tree_layout
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_list_layout
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_in
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_out
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_reset
);
GtkWidget
*
view
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_View"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
view
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
view
),
GTK_WIDGET
(
view_menu
));
// Help entry
// Help entry
GtkWidget
*
help_help
=
gtk_image_menu_item_new_from_stock
(
GTK_STOCK_HELP
,
accel_g
);
GtkWidget
*
help_overview
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Overview"
));
g_signal_connect
(
help_help
,
"activate"
,
G_CALLBACK
(
xtttbl_activate_help
),
this
);
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
help_overview
),
gtk_image_new_from_stock
(
"gtk-help"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
help_overview
,
"activate"
,
G_CALLBACK
(
activate_help
),
this
);
gtk_widget_add_accelerator
(
help_overview
,
"activate"
,
accel_g
,
'h'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
help_project
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Project"
));
g_signal_connect
(
help_project
,
"activate"
,
G_CALLBACK
(
activate_help_project
),
this
);
GtkWidget
*
help_proview
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_About Proview"
));
g_signal_connect
(
help_proview
,
"activate"
,
G_CALLBACK
(
activate_help_proview
),
this
);
GtkMenu
*
help_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
GtkMenu
*
help_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
help_menu
),
help_help
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
help_menu
),
help_overview
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
help_menu
),
help_project
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
help_menu
),
help_proview
);
GtkWidget
*
help
=
gtk_menu_item_new_with_mnemonic
(
"_Help"
);
GtkWidget
*
help
=
gtk_menu_item_new_with_mnemonic
(
"_Help"
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
help
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
help
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
help
),
GTK_WIDGET
(
help_menu
));
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
help
),
GTK_WIDGET
(
help_menu
));
pane
=
gtk_vpaned_new
();
// Toolbar
GtkToolbar
*
tools
=
(
GtkToolbar
*
)
g_object_new
(
GTK_TYPE_TOOLBAR
,
NULL
);
tblnav
=
new
TblNavGtk
(
this
,
pane
,
itemlist
,
item_cnt
,
&
brow_widget
,
&
sts
);
GtkWidget
*
tools_opendshist
=
gtk_button_new
();
tblnav
->
message_cb
=
&
XttTbl
::
message
;
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_meth_trend.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_opendshist
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_opendshist
,
"clicked"
,
G_CALLBACK
(
activate_opendshist
),
this
);
g_object_set
(
tools_opendshist
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_opendshist
,
CoWowGtk
::
translate_utf8
(
"Open hist item"
),
""
);
GtkWidget
*
tools_zoom_in
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_zoom_in.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_in
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_zoom_in
,
"clicked"
,
G_CALLBACK
(
activate_zoom_in
),
this
);
g_object_set
(
tools_zoom_in
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_in
,
CoWowGtk
::
translate_utf8
(
"Zoom in"
),
""
);
GtkWidget
*
tools_zoom_out
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_zoom_out.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_out
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_zoom_out
,
"clicked"
,
G_CALLBACK
(
activate_zoom_out
),
this
);
g_object_set
(
tools_zoom_out
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_out
,
CoWowGtk
::
translate_utf8
(
"Zoom out"
),
""
);
GtkWidget
*
tools_zoom_reset
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_zoom_reset.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_reset
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_zoom_reset
,
"clicked"
,
G_CALLBACK
(
activate_zoom_reset
),
this
);
g_object_set
(
tools_zoom_reset
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_reset
,
CoWowGtk
::
translate_utf8
(
"Zoom reset"
),
""
);
// Statusbar and cmd input
GtkWidget
*
statusbar
=
gtk_hbox_new
(
FALSE
,
0
);
GtkWidget
*
statusbar
=
gtk_hbox_new
(
FALSE
,
0
);
// msg_label = gtk_statusbar_new();
msg_label
=
gtk_label_new
(
""
);
msg_label
=
gtk_label_new
(
""
);
gtk_widget_set_size_request
(
msg_label
,
-
1
,
25
);
gtk_widget_set_size_request
(
msg_label
,
-
1
,
25
);
cmd_prompt
=
gtk_label_new
(
"xtt > "
);
gtk_box_pack_start
(
GTK_BOX
(
statusbar
),
msg_label
,
FALSE
,
FALSE
,
0
);
gtk_widget_set_size_request
(
cmd_prompt
,
-
1
,
25
);
cmd_recall
=
new
CoWowRecall
();
cmd_entry
=
new
CoWowEntryGtk
(
cmd_recall
);
cmd_input
=
cmd_entry
->
widget
();
gtk_widget_set_size_request
(
cmd_input
,
-
1
,
25
);
g_signal_connect
(
cmd_input
,
"activate"
,
G_CALLBACK
(
valchanged_cmd_input
),
this
);
gtk_box_pack_start
(
GTK_BOX
(
statusbar
),
msg_label
,
FALSE
,
FALSE
,
20
);
gtk_box_pack_start
(
GTK_BOX
(
statusbar
),
cmd_prompt
,
FALSE
,
FALSE
,
20
);
gtk_box_pack_start
(
GTK_BOX
(
statusbar
),
cmd_input
,
TRUE
,
TRUE
,
20
);
gtk_widget_show_all
(
statusbar
);
tblnav
=
new
TblNavGtk
(
this
,
toplevel
,
itemlist
,
item_cnt
,
&
brow_widget
,
&
sts
);
tblnav
->
message_cb
=
&
XttTbl
::
message
;
tblnav
->
is_authorized_cb
=
&
XttTbl
::
is_authorized
;
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
menu_bar
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
menu_bar
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
pane
),
TRUE
,
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
tools
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
brow_widget
),
TRUE
,
TRUE
,
0
);
gtk_paned_pack1
(
GTK_PANED
(
pane
),
GTK_WIDGET
(
brow_widget
),
TRUE
,
TRUE
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
statusbar
),
FALSE
,
FALSE
,
3
);
gtk_paned_pack2
(
GTK_PANED
(
pane
),
GTK_WIDGET
(
statusbar
),
FALSE
,
TRUE
);
gtk_container_add
(
GTK_CONTAINER
(
toplevel
),
vbox
);
gtk_container_add
(
GTK_CONTAINER
(
toplevel
),
vbox
);
gtk_widget_show_all
(
toplevel
);
gtk_widget_show_all
(
toplevel
);
int
w
,
h
;
g_object_set
(
cmd_prompt
,
"visible"
,
FALSE
,
NULL
);
gdk_drawable_get_size
(
pane
->
window
,
&
w
,
&
h
);
g_object_set
(
cmd_input
,
"visible"
,
FALSE
,
NULL
);
gtk_paned_set_position
(
GTK_PANED
(
pane
),
h
-
50
);
// Create help window
CoXHelp
*
xhelp
=
new
CoXHelpGtk
(
toplevel
,
this
,
xhelp_eUtility_Xtt
,
&
sts
);
CoXHelp
::
set_default
(
xhelp
);
wow
=
new
CoWowGtk
(
toplevel
);
if
(
!
is_authorized
(
pwr_mAccess_AllSev
,
0
))
open_login
();
if
(
!
quiet
)
{
if
(
cologin
)
// Set login window as parent to warranty as focus is left to parent.
((
CoWowGtk
*
)
wow
)
->
SetParent
(
((
CoLoginGtk
*
)
cologin
)
->
widgets
.
toplevel
);
wow
->
DisplayWarranty
();
if
(
cologin
)
((
CoWowGtk
*
)
wow
)
->
SetParent
(
toplevel
);
}
}
}
XttTblGtk
::~
XttTblGtk
()
XttTblGtk
::~
XttTblGtk
()
...
...
sev/exe/sev_xtt/gtk/xtt_tbl_gtk.h
View file @
7a20e851
/*
/*
* Proview $Id: xtt_tbl_gtk.h,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: xtt_tbl_gtk.h,v 1.
2 2008-09-05 08:38:58
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
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
/* ge_tbl.h -- Ge tblibute editor */
/* ge_tbl.h -- Ge tblibute editor */
class
CoWowRecall
;
class
CoWowEntryGtk
;
class
XttTblGtk
:
public
XttTbl
{
class
XttTblGtk
:
public
XttTbl
{
public:
public:
...
@@ -40,10 +42,37 @@ class XttTblGtk : public XttTbl {
...
@@ -40,10 +42,37 @@ class XttTblGtk : public XttTbl {
GtkWidget
*
form_widget
;
GtkWidget
*
form_widget
;
GtkWidget
*
toplevel
;
GtkWidget
*
toplevel
;
GtkWidget
*
msg_label
;
GtkWidget
*
msg_label
;
GtkWidget
*
cmd_prompt
;
GtkWidget
*
cmd_input
;
GtkWidget
*
pane
;
GtkWidget
*
pane
;
CoWowRecall
*
cmd_recall
;
CoWowEntryGtk
*
cmd_entry
;
void
message
(
char
severity
,
char
*
message
);
void
message
(
char
severity
,
char
*
message
);
XttDsHist
*
dshist_new
(
pwr_tOid
oid
,
char
*
aname
);
XttDsHist
*
dshist_new
(
pwr_tOid
oid
,
char
*
aname
);
CoLogin
*
login_new
(
char
*
wl_name
,
char
*
wl_groupname
,
void
(
*
wl_bc_success
)(
void
*
),
void
(
*
wl_bc_cancel
)(
void
*
),
pwr_tStatus
*
status
);
void
set_prompt
(
char
*
prompt
);
static
void
activate_command
(
GtkWidget
*
w
,
gpointer
data
);
static
void
valchanged_cmd_input
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_print
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_login
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_logout
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_close
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_opendshist
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_delete_item
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_tree_layout
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_list_layout
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_help
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_help_project
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_help_proview
(
GtkWidget
*
w
,
gpointer
data
);
~
XttTblGtk
();
~
XttTblGtk
();
};
};
...
...
sev/exe/sev_xtt/src/xtt_tbl.cpp
View file @
7a20e851
/*
/*
* Proview $Id: xtt_tbl.cpp,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: xtt_tbl.cpp,v 1.
2 2008-09-05 08:38:58
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
...
@@ -26,6 +26,10 @@
...
@@ -26,6 +26,10 @@
#include <vector.h>
#include <vector.h>
#include "co_cdh.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_time.h"
#include "co_xhelp.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "co_cnf.h"
#include "flow.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browctx.h"
...
@@ -44,8 +48,28 @@ XttTbl::~XttTbl()
...
@@ -44,8 +48,28 @@ XttTbl::~XttTbl()
}
}
XttTbl
::
XttTbl
(
void
*
xn_parent_ctx
,
sevcli_tCtx
xn_sevcli
)
:
XttTbl
::
XttTbl
(
void
*
xn_parent_ctx
,
sevcli_tCtx
xn_sevcli
)
:
parent_ctx
(
xn_parent_ctx
),
sevcli
(
xn_sevcli
)
parent_ctx
(
xn_parent_ctx
),
sevcli
(
xn_sevcli
),
command_open
(
0
),
close_cb
(
0
),
base_priv
(
pwr_mPrv_System
),
priv
(
pwr_mPrv_System
),
verify
(
0
),
ccm_func_registred
(
0
),
quiet
(
0
)
{
{
char
default_priv
[
80
];
strcpy
(
base_user
,
""
);
strcpy
(
user
,
""
);
// Get default privilete from proview.cnf
if
(
cnf_get_value
(
"sevXttDefaultPriv"
,
default_priv
))
{
if
(
cdh_NoCaseStrcmp
(
default_priv
,
"READ"
)
==
0
)
priv
=
pwr_mPrv_SevRead
;
else
if
(
cdh_NoCaseStrcmp
(
default_priv
,
"ADMIN"
)
==
0
)
priv
=
pwr_mPrv_SevAdmin
;
else
if
(
cdh_NoCaseStrcmp
(
default_priv
,
"NONE"
)
==
0
)
priv
=
0
;
else
priv
=
0
;
}
else
priv
=
0
;
}
}
void
XttTbl
::
message
(
void
*
xtttbl
,
char
severity
,
char
*
message
)
void
XttTbl
::
message
(
void
*
xtttbl
,
char
severity
,
char
*
message
)
...
@@ -53,6 +77,47 @@ void XttTbl::message( void *xtttbl, char severity, char *message)
...
@@ -53,6 +77,47 @@ void XttTbl::message( void *xtttbl, char severity, char *message)
((
XttTbl
*
)
xtttbl
)
->
message
(
severity
,
message
);
((
XttTbl
*
)
xtttbl
)
->
message
(
severity
,
message
);
}
}
int
XttTbl
::
is_authorized
(
void
*
ctx
,
unsigned
int
access
,
int
msg
)
{
return
((
XttTbl
*
)
ctx
)
->
is_authorized
(
access
,
msg
);
}
int
XttTbl
::
is_authorized
(
unsigned
int
access
,
int
msg
)
{
if
(
!
(
priv
&
access
))
{
if
(
msg
)
message
(
'I'
,
"Not authorized for this operation"
);
return
0
;
}
return
1
;
}
void
XttTbl
::
open_login
()
{
pwr_tCmd
cmd
;
strcpy
(
cmd
,
"login"
);
command
(
cmd
);
}
void
XttTbl
::
logout
()
{
pwr_tCmd
cmd
;
strcpy
(
cmd
,
"logout"
);
command
(
cmd
);
}
void
XttTbl
::
activate_print
()
{
pwr_tFileName
filename
;
pwr_tCmd
cmd
;
dcli_translate_filename
(
filename
,
"$pwrp_tmp/sevxtt.ps"
);
tblnav
->
print
(
filename
);
sprintf
(
cmd
,
"$pwr_exe/rt_print.sh %s"
,
filename
);
system
(
cmd
);
}
void
XttTbl
::
activate_opendshist
()
void
XttTbl
::
activate_opendshist
()
{
{
sevcli_sHistItem
*
hi
;
sevcli_sHistItem
*
hi
;
...
@@ -61,3 +126,78 @@ void XttTbl::activate_opendshist()
...
@@ -61,3 +126,78 @@ void XttTbl::activate_opendshist()
dshist_new
(
hi
->
oid
,
hi
->
aname
);
dshist_new
(
hi
->
oid
,
hi
->
aname
);
}
}
void
XttTbl
::
delete_item_yes
(
void
*
ctx
,
void
*
data
)
{
XttTbl
*
tbl
=
(
XttTbl
*
)
ctx
;
sevcli_sHistItem
*
hi
=
(
sevcli_sHistItem
*
)
data
;
pwr_tStatus
sts
;
printf
(
"Deleting %s
\n
"
,
hi
->
oname
);
sevcli_delete_item
(
&
sts
,
tbl
->
sevcli
,
hi
->
oid
,
hi
->
aname
);
if
(
EVEN
(
sts
))
{
tbl
->
message
(
'E'
,
"Delete error"
);
return
;
}
tbl
->
tblnav
->
delete_item
(
hi
);
tbl
->
message
(
'I'
,
"Item deleted"
);
}
void
XttTbl
::
activate_delete_item
()
{
sevcli_sHistItem
*
hi
;
char
msg
[
300
];
if
(
!
tblnav
->
get_select
(
&
hi
))
{
message
(
'E'
,
"Select an storage item"
);
return
;
}
sprintf
(
msg
,
"Do you really wan't to delete all stored data for item
\n\n
%s.%s
\n
"
,
hi
->
oname
,
hi
->
aname
);
wow
->
DisplayQuestion
(
this
,
"Confirm Delete Item"
,
msg
,
delete_item_yes
,
0
,
hi
);
}
void
XttTbl
::
activate_zoom_in
()
{
double
zoom_factor
;
tblnav
->
get_zoom
(
&
zoom_factor
);
if
(
zoom_factor
>
40
)
return
;
tblnav
->
zoom
(
1.18
);
}
void
XttTbl
::
activate_zoom_out
()
{
double
zoom_factor
;
tblnav
->
get_zoom
(
&
zoom_factor
);
if
(
zoom_factor
<
15
)
return
;
tblnav
->
zoom
(
1.0
/
1.18
);
}
void
XttTbl
::
activate_zoom_reset
()
{
tblnav
->
unzoom
();
}
void
XttTbl
::
activate_help
()
{
CoXHelp
::
dhelp
(
"overview"
,
""
,
navh_eHelpFile_Base
,
NULL
,
0
);
}
void
XttTbl
::
activate_help_project
()
{
CoXHelp
::
dhelp
(
"index"
,
""
,
navh_eHelpFile_Project
,
NULL
,
0
);
}
void
XttTbl
::
activate_help_proview
()
{
CoXHelp
::
dhelp
(
"version"
,
""
,
navh_eHelpFile_Other
,
"$pwr_exe/sev_xtt_version_help.dat"
,
0
);
}
sev/exe/sev_xtt/src/xtt_tbl.h
View file @
7a20e851
/*
/*
* Proview $Id: xtt_tbl.h,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: xtt_tbl.h,v 1.
2 2008-09-05 08:38:58
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
...
@@ -20,6 +20,10 @@
...
@@ -20,6 +20,10 @@
#ifndef xtt_tbl_h
#ifndef xtt_tbl_h
#define xtt_tbl_h
#define xtt_tbl_h
#ifndef pwr_privilege_h
#include "pwr_privilege.h"
#endif
#include "glow.h"
#include "glow.h"
#include "rt_sevcli.h"
#include "rt_sevcli.h"
...
@@ -28,21 +32,59 @@
...
@@ -28,21 +32,59 @@
class
TblNav
;
class
TblNav
;
class
XttDsHist
;
class
XttDsHist
;
class
CoLogin
;
class
CoWow
;
class
XttTbl
{
class
XttTbl
{
public:
public:
XttTbl
(
void
*
xn_parent_ctx
,
sevcli_tCtx
xn_sevcli
);
XttTbl
(
void
*
xn_parent_ctx
,
sevcli_tCtx
xn_sevcli
);
void
*
parent_ctx
;
void
*
parent_ctx
;
char
name
[
80
];
char
name
[
80
];
TblNav
*
tblnav
;
TblNav
*
tblnav
;
sevcli_tCtx
sevcli
;
sevcli_tCtx
sevcli
;
CoLogin
*
cologin
;
int
command_open
;
void
(
*
close_cb
)(
void
*
);
char
base_user
[
80
];
char
user
[
80
];
unsigned
int
base_priv
;
unsigned
int
priv
;
int
verify
;
int
ccm_func_registred
;
CoWow
*
wow
;
int
quiet
;
virtual
void
message
(
char
severity
,
char
*
message
)
{}
virtual
void
message
(
char
severity
,
char
*
message
)
{}
virtual
XttDsHist
*
dshist_new
(
pwr_tOid
oid
,
char
*
aname
)
{
return
0
;}
virtual
XttDsHist
*
dshist_new
(
pwr_tOid
oid
,
char
*
aname
)
{
return
0
;}
virtual
CoLogin
*
login_new
(
char
*
wl_name
,
char
*
wl_groupname
,
void
(
*
wl_bc_success
)(
void
*
),
void
(
*
wl_bc_cancel
)(
void
*
),
pwr_tStatus
*
status
)
{
return
0
;}
virtual
void
set_prompt
(
char
*
prompt
)
{}
int
is_authorized
(
unsigned
int
access
=
pwr_mAccess_AllSev
,
int
msg
=
1
);
void
open_login
();
void
logout
();
void
activate_print
();
void
activate_opendshist
();
void
activate_opendshist
();
void
activate_delete_item
();
void
activate_zoom_in
();
void
activate_zoom_out
();
void
activate_zoom_reset
();
void
activate_help
();
void
activate_help_project
();
void
activate_help_proview
();
static
void
message
(
void
*
attr
,
char
severity
,
char
*
message
);
static
void
message
(
void
*
attr
,
char
severity
,
char
*
message
);
static
int
is_authorized
(
void
*
ctx
,
unsigned
int
access
,
int
msg
);
static
void
delete_item_yes
(
void
*
ctx
,
void
*
data
);
virtual
~
XttTbl
();
virtual
~
XttTbl
();
int
command
(
char
*
input_str
);
int
readcmdfile
(
char
*
incommand
);
int
read_bootfile
(
char
*
systemname
,
char
*
systemgroup
);
};
};
...
...
sev/exe/sev_xtt/src/xtt_tbl_command.cpp
0 → 100644
View file @
7a20e851
/*
* Proview $Id: xtt_tbl_command.cpp,v 1.1 2008-09-05 08:38:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_tbl_command.cpp
This module contains routines for handling of command line in sevxtt. */
#include "flow_std.h"
# include <vector>
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <ctype.h>
#include "co_nav_help.h"
#include "pwr_privilege.h"
#include "co_cdh.h"
#include "co_ccm.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_user.h"
#include "co_ccm_msg.h"
#include "co_api_user.h"
#include "co_syi.h"
#include "co_dbs.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_lng.h"
#include "co_error.h"
#include "co_wow.h"
#include "xtt_tbl.h"
#include "co_dcli_msg.h"
#include "co_xhelp.h"
#include "co_login.h"
#define XTTTBL__HOLDCOMMAND 21;
#define XTTTBL__SUCCESS 23;
static
pwr_tStatus
command_sts
=
1
;
static
XttTbl
*
current_xtttbl
;
static
int
xtttbl_exit_func
(
void
*
client_data
,
void
*
client_flag
);
static
int
xtttbl_help_func
(
void
*
client_data
,
void
*
client_flag
);
static
int
xtttbl_logout_func
(
void
*
client_data
,
void
*
client_flag
);
static
int
xtttbl_login_func
(
void
*
client_data
,
void
*
client_flag
);
static
int
xtttbl_open_func
(
void
*
client_data
,
void
*
client_flag
);
static
int
xtttbl_show_func
(
void
*
client_data
,
void
*
client_flag
);
dcli_tCmdTable
xtttbl_command_table
[]
=
{
{
"OPEN"
,
&
xtttbl_open_func
,
{
"dcli_arg1"
,
""
}
},
{
"SHOW"
,
&
xtttbl_show_func
,
{
"dcli_arg1"
,
""
}
},
{
"EXIT"
,
&
xtttbl_exit_func
,
{
""
,}
},
{
"QUIT"
,
&
xtttbl_exit_func
,
{
""
,}
},
{
"HELP"
,
&
xtttbl_help_func
,
{
"dcli_arg1"
,
"dcli_arg2"
,
"dcli_arg3"
,
"dcli_arg4"
,
"/HELPFILE"
,
"/POPNAVIGATOR"
,
"/BOOKMARK"
,
"/INDEX"
,
"/BASE"
,
"/RETURNCOMMAND"
,
"/WIDTH"
,
"/HEIGHT"
,
"/VERSION"
,
""
}
},
{
"LOGOUT"
,
&
xtttbl_logout_func
,
{
""
}
},
{
"LOGIN"
,
&
xtttbl_login_func
,
{
"dcli_arg1"
,
"dcli_arg2"
,
""
}
},
{
""
,}};
static
void
xtttbl_store_xtttbl
(
XttTbl
*
xtttbl
)
{
current_xtttbl
=
xtttbl
;
}
#if 0
static void xtttbl_get_stored_xtttbl( XttTbl **xtttbl)
{
*xtttbl = current_xtttbl;
}
#endif
static
int
xtttbl_help_func
(
void
*
client_data
,
void
*
client_flag
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
int
sts
;
char
arg_str
[
80
];
char
file_str
[
80
];
char
bookmark_str
[
80
];
char
key
[
80
];
char
return_str
[
80
];
int
pop
;
int
width
,
height
;
int
nr
;
if
(
ODD
(
dcli_get_qualifier
(
"/INDEX"
,
file_str
,
sizeof
(
file_str
))))
{
if
(
ODD
(
dcli_get_qualifier
(
"/HELPFILE"
,
file_str
,
sizeof
(
file_str
))))
{
sts
=
CoXHelp
::
dhelp_index
(
navh_eHelpFile_Other
,
file_str
);
if
(
EVEN
(
sts
))
xtttbl
->
message
(
'E'
,
"Unable to find file"
);
}
else
{
if
(
ODD
(
dcli_get_qualifier
(
"/BASE"
,
0
,
0
)))
sts
=
CoXHelp
::
dhelp_index
(
navh_eHelpFile_Base
,
NULL
);
else
sts
=
CoXHelp
::
dhelp_index
(
navh_eHelpFile_Project
,
NULL
);
}
return
1
;
}
if
(
ODD
(
dcli_get_qualifier
(
"/VERSION"
,
0
,
0
)))
{
sts
=
CoXHelp
::
dhelp
(
"version"
,
""
,
navh_eHelpFile_Other
,
"$pwr_exe/xtt_version_help.dat"
,
0
);
if
(
EVEN
(
sts
))
xtttbl
->
message
(
'E'
,
"No help on this subject"
);
return
sts
;
}
int
strict
=
0
;
if
(
EVEN
(
dcli_get_qualifier
(
"dcli_arg1"
,
arg_str
,
sizeof
(
arg_str
))))
{
sts
=
CoXHelp
::
dhelp
(
"help command"
,
""
,
navh_eHelpFile_Base
,
NULL
,
strict
);
return
1
;
}
if
(
EVEN
(
dcli_get_qualifier
(
"/BOOKMARK"
,
bookmark_str
,
sizeof
(
bookmark_str
))))
strcpy
(
bookmark_str
,
""
);
strcpy
(
key
,
arg_str
);
if
(
ODD
(
dcli_get_qualifier
(
"dcli_arg2"
,
arg_str
,
sizeof
(
arg_str
))))
{
strcat
(
key
,
" "
);
strcat
(
key
,
arg_str
);
if
(
ODD
(
dcli_get_qualifier
(
"dcli_arg3"
,
arg_str
,
sizeof
(
arg_str
))))
{
strcat
(
key
,
" "
);
strcat
(
key
,
arg_str
);
if
(
ODD
(
dcli_get_qualifier
(
"dcli_arg3"
,
arg_str
,
sizeof
(
arg_str
))))
{
strcat
(
key
,
" "
);
strcat
(
key
,
arg_str
);
if
(
ODD
(
dcli_get_qualifier
(
"dcli_arg4"
,
arg_str
,
sizeof
(
arg_str
))))
{
strcat
(
key
,
" "
);
strcat
(
key
,
arg_str
);
}
}
}
}
if
(
!
ODD
(
dcli_get_qualifier
(
"/RETURNCOMMAND"
,
return_str
,
sizeof
(
return_str
))))
strcpy
(
return_str
,
""
);
if
(
ODD
(
dcli_get_qualifier
(
"/WIDTH"
,
arg_str
,
sizeof
(
arg_str
))))
{
// convert to integer
nr
=
sscanf
(
arg_str
,
"%d"
,
&
width
);
if
(
nr
!=
1
)
{
xtttbl
->
message
(
'E'
,
"Width syntax error"
);
return
XTTTBL__HOLDCOMMAND
;
}
}
else
width
=
0
;
if
(
ODD
(
dcli_get_qualifier
(
"/HEIGHT"
,
arg_str
,
sizeof
(
arg_str
))))
{
// convert to integer
nr
=
sscanf
(
arg_str
,
"%d"
,
&
height
);
if
(
nr
!=
1
)
{
xtttbl
->
message
(
'E'
,
"Height syntax error"
);
return
XTTTBL__HOLDCOMMAND
;
}
}
else
height
=
0
;
pop
=
ODD
(
dcli_get_qualifier
(
"/POPNAVIGATOR"
,
0
,
0
));
if
(
ODD
(
dcli_get_qualifier
(
"/HELPFILE"
,
file_str
,
sizeof
(
file_str
))))
{
sts
=
CoXHelp
::
dhelp
(
key
,
bookmark_str
,
navh_eHelpFile_Other
,
file_str
,
strict
);
if
(
EVEN
(
sts
))
xtttbl
->
message
(
'E'
,
"No help on this subject"
);
}
else
if
(
ODD
(
dcli_get_qualifier
(
"/BASE"
,
0
,
0
)))
{
sts
=
CoXHelp
::
dhelp
(
key
,
bookmark_str
,
navh_eHelpFile_Base
,
0
,
strict
);
if
(
EVEN
(
sts
))
xtttbl
->
message
(
'E'
,
"No help on this subject"
);
}
else
{
sts
=
CoXHelp
::
dhelp
(
key
,
bookmark_str
,
navh_eHelpFile_Base
,
0
,
strict
);
if
(
EVEN
(
sts
))
{
sts
=
CoXHelp
::
dhelp
(
key
,
bookmark_str
,
navh_eHelpFile_Project
,
0
,
strict
);
if
(
EVEN
(
sts
))
xtttbl
->
message
(
'E'
,
"No help on this subject"
);
}
}
return
1
;
}
static
void
xtttbl_login_success_bc
(
void
*
ctx
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
ctx
;
char
msg
[
80
];
CoLogin
::
get_login_info
(
0
,
0
,
xtttbl
->
user
,
(
unsigned
long
*
)
&
xtttbl
->
priv
,
0
);
sprintf
(
msg
,
"User %s logged in"
,
xtttbl
->
user
);
xtttbl
->
cologin
=
0
;
xtttbl
->
message
(
'I'
,
msg
);
}
static
void
xtttbl_login_cancel_bc
(
void
*
xtttbl
)
{
((
XttTbl
*
)
xtttbl
)
->
cologin
=
0
;
}
static
int
xtttbl_exit_func
(
void
*
client_data
,
void
*
client_flag
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
if
(
xtttbl
->
close_cb
)
(
xtttbl
->
close_cb
)(
xtttbl
->
parent_ctx
);
else
exit
(
1
);
return
1
;
}
static
int
xtttbl_login_func
(
void
*
client_data
,
void
*
client_flag
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
int
sts
;
char
arg1_str
[
80
];
char
arg2_str
[
80
];
char
systemgroup
[
80
];
unsigned
int
priv
;
char
msg
[
80
];
// sts = gdh_GetObjectInfo ( "pwrNode-System.SystemGroup", &systemgroup,
// sizeof(systemgroup));
// if ( EVEN(sts)) return sts;
sts
=
xtttbl
->
read_bootfile
(
0
,
systemgroup
);
if
(
EVEN
(
dcli_get_qualifier
(
"dcli_arg1"
,
arg1_str
,
sizeof
(
arg1_str
))))
{
xtttbl
->
cologin
=
xtttbl
->
login_new
(
"PwR Login"
,
systemgroup
,
xtttbl_login_success_bc
,
xtttbl_login_cancel_bc
,
&
sts
);
return
1
;
}
if
(
EVEN
(
dcli_get_qualifier
(
"dcli_arg2"
,
arg2_str
,
sizeof
(
arg2_str
))))
{
xtttbl
->
message
(
'E'
,
"Syntax error"
);
return
1
;
}
cdh_ToLower
(
arg1_str
,
arg1_str
);
cdh_ToLower
(
arg2_str
,
arg2_str
);
sts
=
user_CheckUser
(
systemgroup
,
arg1_str
,
UserList
::
pwcrypt
(
arg2_str
),
&
priv
);
if
(
EVEN
(
sts
))
xtttbl
->
message
(
'E'
,
"Login failure"
);
else
{
strcpy
(
xtttbl
->
user
,
arg1_str
);
xtttbl
->
priv
=
priv
;
sprintf
(
msg
,
"User %s logged in"
,
arg1_str
);
xtttbl
->
message
(
'I'
,
msg
);
}
return
sts
;
}
static
int
xtttbl_logout_func
(
void
*
client_data
,
void
*
client_flag
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
char
msg
[
80
];
if
(
strcmp
(
xtttbl
->
base_user
,
""
)
==
0
)
{
sprintf
(
msg
,
"User %s logged out"
,
xtttbl
->
user
);
xtttbl
->
message
(
'I'
,
msg
);
}
else
{
sprintf
(
msg
,
"Returned to user %s"
,
xtttbl
->
base_user
);
xtttbl
->
message
(
'I'
,
msg
);
}
strcpy
(
xtttbl
->
user
,
xtttbl
->
base_user
);
xtttbl
->
priv
=
xtttbl
->
base_priv
;
return
1
;
}
static
int
xtttbl_open_func
(
void
*
client_data
,
void
*
client_flag
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
char
arg1_str
[
80
];
int
arg1_sts
;
arg1_sts
=
dcli_get_qualifier
(
"dcli_arg1"
,
arg1_str
,
sizeof
(
arg1_str
));
if
(
strncmp
(
arg1_str
,
"GRAPH"
,
strlen
(
arg1_str
))
==
0
)
{
}
else
xtttbl
->
message
(
'E'
,
"Syntax error"
);
return
XTTTBL__SUCCESS
;
}
static
int
xtttbl_show_func
(
void
*
client_data
,
void
*
client_flag
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
char
arg1_str
[
80
];
int
arg1_sts
;
arg1_sts
=
dcli_get_qualifier
(
"dcli_arg1"
,
arg1_str
,
sizeof
(
arg1_str
));
if
(
strncmp
(
arg1_str
,
"USER"
,
strlen
(
arg1_str
))
==
0
)
{
char
msg
[
120
];
char
priv_str
[
80
];
if
(
strcmp
(
xtttbl
->
user
,
""
)
==
0
)
{
user_RtPrivToString
(
xtttbl
->
priv
,
priv_str
,
sizeof
(
priv_str
));
sprintf
(
msg
,
"Not logged in (%s)"
,
priv_str
);
xtttbl
->
message
(
'I'
,
msg
);
}
else
{
user_RtPrivToString
(
xtttbl
->
priv
,
priv_str
,
sizeof
(
priv_str
));
sprintf
(
msg
,
"User %s (%s)"
,
xtttbl
->
user
,
priv_str
);
xtttbl
->
message
(
'I'
,
msg
);
}
}
else
xtttbl
->
message
(
'E'
,
"Syntax error"
);
return
1
;
}
int
XttTbl
::
command
(
char
*
input_str
)
{
char
command
[
1000
];
int
sts
,
sym_sts
;
char
symbol_value
[
DCLI_SYM_VALUE_SIZE
];
if
(
input_str
[
0
]
==
'@'
)
{
sts
=
dcli_replace_symbol
(
input_str
,
command
,
sizeof
(
command
));
if
(
EVEN
(
sts
))
return
sts
;
/* Read command file */
sts
=
readcmdfile
(
&
command
[
1
]);
if
(
sts
==
DCLI__NOFILE
)
{
message
(
'E'
,
"Unable to open file"
);
return
DCLI__SUCCESS
;
}
else
if
(
EVEN
(
sts
))
return
sts
;
return
DCLI__SUCCESS
;
}
dcli_toupper
(
input_str
,
input_str
);
sts
=
dcli_replace_symbol
(
input_str
,
command
,
sizeof
(
command
));
if
(
EVEN
(
sts
))
return
sts
;
sts
=
dcli_cli
(
(
dcli_tCmdTable
*
)
&
xtttbl_command_table
,
command
,
(
void
*
)
this
,
0
);
if
(
sts
==
DCLI__COM_NODEF
)
{
/* Try to find a matching symbol */
sym_sts
=
dcli_get_symbol_cmd
(
command
,
symbol_value
);
if
(
ODD
(
sym_sts
))
{
if
(
symbol_value
[
0
]
==
'@'
)
{
/* Read command file */
sts
=
readcmdfile
(
&
symbol_value
[
1
]);
if
(
sts
==
DCLI__NOFILE
)
{
message
(
'E'
,
"Unable to open file"
);
return
DCLI__SUCCESS
;
}
else
if
(
EVEN
(
sts
))
return
sts
;
return
DCLI__SUCCESS
;
}
sts
=
dcli_cli
(
(
dcli_tCmdTable
*
)
&
xtttbl_command_table
,
symbol_value
,
(
void
*
)
this
,
0
);
}
else
if
(
sym_sts
==
DCLI__SYMBOL_AMBIG
)
sts
=
sym_sts
;
}
if
(
sts
==
DCLI__COM_AMBIG
)
message
(
'E'
,
"Ambiguous command"
);
else
if
(
sts
==
DCLI__COM_NODEF
)
message
(
'E'
,
"Undefined command"
);
else
if
(
sts
==
DCLI__QUAL_AMBIG
)
message
(
'E'
,
"Ambiguous qualifier"
);
else
if
(
sts
==
DCLI__QUAL_NODEF
)
message
(
'E'
,
"Undefined qualifier"
);
else
if
(
sts
==
DCLI__SYMBOL_AMBIG
)
message
(
'E'
,
"Ambiguous symbol abbrevation"
);
command_sts
=
sts
;
return
DCLI__SUCCESS
;
}
static
int
xtttbl_ccm_errormessage_func
(
char
*
msg
,
int
severity
,
void
*
client_data
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
if
(
EVEN
(
severity
))
xtttbl
->
message
(
'I'
,
msg
);
else
xtttbl
->
message
(
'E'
,
msg
);
return
1
;
}
static
int
xtttbl_ccm_deffilename_func
(
char
*
outfile
,
char
*
infile
,
void
*
client_data
)
{
pwr_tFileName
fname
;
dcli_translate_filename
(
fname
,
infile
);
dcli_get_defaultfilename
(
fname
,
outfile
,
".rtt_com"
);
return
1
;
}
int
xtttbl_externcmd_func
(
char
*
cmd
,
void
*
client_data
)
{
XttTbl
*
xtttbl
=
(
XttTbl
*
)
client_data
;
return
xtttbl
->
command
(
cmd
);
}
int
XttTbl
::
readcmdfile
(
char
*
incommand
)
{
char
input_str
[
160
];
int
sts
;
int
appl_sts
;
if
(
!
ccm_func_registred
)
{
ccm_func_registred
=
1
;
}
strcpy
(
input_str
,
incommand
);
dcli_remove_blank
(
input_str
,
input_str
);
xtttbl_store_xtttbl
(
this
);
/* Read and execute the command file */
sts
=
ccm_file_exec
(
input_str
,
xtttbl_externcmd_func
,
xtttbl_ccm_deffilename_func
,
xtttbl_ccm_errormessage_func
,
&
appl_sts
,
verify
,
0
,
NULL
,
0
,
0
,
NULL
,
(
void
*
)
this
);
if
(
EVEN
(
sts
))
return
sts
;
return
1
;
}
int
XttTbl
::
read_bootfile
(
char
*
systemname
,
char
*
systemgroup
)
{
pwr_tFileName
fname
;
char
nodename
[
80
];
int
busid
;
FILE
*
fp
;
char
buffer
[
256
];
pwr_tStatus
sts
;
char
*
s
;
syi_NodeName
(
&
sts
,
nodename
,
sizeof
(
nodename
));
s
=
getenv
(
pwr_dEnvBusId
);
if
(
!
s
)
return
0
;
busid
=
atoi
(
s
);
sprintf
(
fname
,
dbs_cNameBoot
,
"$pwrp_load/"
,
nodename
,
busid
);
dcli_translate_filename
(
fname
,
fname
);
fp
=
fopen
(
fname
,
"r"
);
if
(
!
fp
)
return
0
;
s
=
fgets
(
buffer
,
sizeof
(
buffer
)
-
1
,
fp
);
if
(
!
s
)
return
0
;
s
=
fgets
(
buffer
,
sizeof
(
buffer
)
-
1
,
fp
);
if
(
!
s
)
return
0
;
if
(
systemname
)
{
if
(
buffer
[
strlen
(
buffer
)
-
1
]
==
'\n'
)
buffer
[
strlen
(
buffer
)
-
1
]
=
0
;
strcpy
(
systemname
,
buffer
);
}
s
=
fgets
(
buffer
,
sizeof
(
buffer
)
-
1
,
fp
);
if
(
!
s
)
return
0
;
if
(
systemgroup
)
{
if
(
buffer
[
strlen
(
buffer
)
-
1
]
==
'\n'
)
buffer
[
strlen
(
buffer
)
-
1
]
=
0
;
strcpy
(
systemgroup
,
buffer
);
}
fclose
(
fp
);
return
1
;
}
sev/exe/sev_xtt/src/xtt_tblnav.cpp
View file @
7a20e851
/*
/*
* Proview $Id: xtt_tblnav.cpp,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: xtt_tblnav.cpp,v 1.
2 2008-09-05 08:38:58
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
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "co_cdh.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_time.h"
#include "co_dcli.h"
#include "flow.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browapi.h"
...
@@ -50,6 +51,11 @@ void TblNav::message( char sev, char *text)
...
@@ -50,6 +51,11 @@ void TblNav::message( char sev, char *text)
(
message_cb
)(
parent_ctx
,
sev
,
text
);
(
message_cb
)(
parent_ctx
,
sev
,
text
);
}
}
void
TblNav
::
print
(
char
*
filename
)
{
brow_Print
(
brow
->
ctx
,
filename
);
}
//
//
// Free pixmaps
// Free pixmaps
//
//
...
@@ -122,7 +128,7 @@ TblNav::TblNav(
...
@@ -122,7 +128,7 @@ TblNav::TblNav(
pwr_tStatus
*
status
)
:
pwr_tStatus
*
status
)
:
parent_ctx
(
xn_parent_ctx
),
parent_ctx
(
xn_parent_ctx
),
itemlist
(
xn_itemlist
),
item_cnt
(
xn_item_cnt
),
itemlist
(
xn_itemlist
),
item_cnt
(
xn_item_cnt
),
message_cb
(
NULL
)
message_cb
(
NULL
)
,
list_layout
(
0
)
{
{
*
status
=
1
;
*
status
=
1
;
}
}
...
@@ -139,6 +145,11 @@ TblNavBrow::~TblNavBrow()
...
@@ -139,6 +145,11 @@ TblNavBrow::~TblNavBrow()
free_pixmaps
();
free_pixmaps
();
}
}
int
TblNav
::
is_authorized
(
unsigned
int
access
,
int
msg
)
{
return
(
is_authorized_cb
)(
parent_ctx
,
access
,
msg
);
}
//
//
// Callbacks from brow
// Callbacks from brow
...
@@ -146,7 +157,7 @@ TblNavBrow::~TblNavBrow()
...
@@ -146,7 +157,7 @@ TblNavBrow::~TblNavBrow()
static
int
tblnav_brow_cb
(
FlowCtx
*
ctx
,
flow_tEvent
event
)
static
int
tblnav_brow_cb
(
FlowCtx
*
ctx
,
flow_tEvent
event
)
{
{
TblNav
*
tblnav
;
TblNav
*
tblnav
;
Item
Local
*
item
;
Item
Base
*
item
;
if
(
event
->
event
==
flow_eEvent_ObjectDeleted
)
{
if
(
event
->
event
==
flow_eEvent_ObjectDeleted
)
{
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
...
@@ -155,6 +166,10 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -155,6 +166,10 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
}
}
brow_GetCtxUserData
(
(
BrowCtx
*
)
ctx
,
(
void
**
)
&
tblnav
);
brow_GetCtxUserData
(
(
BrowCtx
*
)
ctx
,
(
void
**
)
&
tblnav
);
if
(
!
tblnav
->
is_authorized
())
return
1
;
tblnav
->
message
(
' '
,
""
);
tblnav
->
message
(
' '
,
""
);
switch
(
event
->
event
)
{
switch
(
event
->
event
)
{
case
flow_eEvent_Key_PageDown
:
{
case
flow_eEvent_Key_PageDown
:
{
...
@@ -244,10 +259,27 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -244,10 +259,27 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
case
flow_eEvent_SelectClear
:
case
flow_eEvent_SelectClear
:
brow_ResetSelectInverse
(
tblnav
->
brow
->
ctx
);
brow_ResetSelectInverse
(
tblnav
->
brow
->
ctx
);
break
;
break
;
case
flow_eEvent_MB1Click
:
case
flow_eEvent_MB1Click
:
{
// Select
// Select
double
ll_x
,
ll_y
,
ur_x
,
ur_y
;
int
sts
;
switch
(
event
->
object
.
object_type
)
{
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
case
flow_eObjectType_Node
:
brow_MeasureNode
(
event
->
object
.
object
,
&
ll_x
,
&
ll_y
,
&
ur_x
,
&
ur_y
);
if
(
event
->
object
.
x
<
ll_x
+
1.0
)
{
// Simulate doubleclick
flow_tEvent
doubleclick_event
;
doubleclick_event
=
(
flow_tEvent
)
calloc
(
1
,
sizeof
(
*
doubleclick_event
));
memcpy
(
doubleclick_event
,
event
,
sizeof
(
*
doubleclick_event
));
doubleclick_event
->
event
=
flow_eEvent_MB1DoubleClick
;
sts
=
tblnav_brow_cb
(
ctx
,
doubleclick_event
);
free
(
(
char
*
)
doubleclick_event
);
return
sts
;
}
if
(
brow_FindSelectedObject
(
tblnav
->
brow
->
ctx
,
event
->
object
.
object
))
{
if
(
brow_FindSelectedObject
(
tblnav
->
brow
->
ctx
,
event
->
object
.
object
))
{
brow_SelectClear
(
tblnav
->
brow
->
ctx
);
brow_SelectClear
(
tblnav
->
brow
->
ctx
);
}
}
...
@@ -261,6 +293,7 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -261,6 +293,7 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_SelectClear
(
tblnav
->
brow
->
ctx
);
brow_SelectClear
(
tblnav
->
brow
->
ctx
);
}
}
break
;
break
;
}
case
flow_eEvent_Key_Left
:
{
case
flow_eEvent_Key_Left
:
{
brow_tNode
*
node_list
;
brow_tNode
*
node_list
;
int
node_count
;
int
node_count
;
...
@@ -283,13 +316,8 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -283,13 +316,8 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
}
}
}
}
brow_GetUserData
(
object
,
(
void
**
)
&
item
);
brow_GetUserData
(
object
,
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
item
->
close
(
tblnav
,
0
,
0
);
case
tblnav_eItemType_Local
:
((
ItemLocal
*
)
item
)
->
close
(
tblnav
,
0
,
0
);
break
;
default:
;
}
brow_SelectClear
(
tblnav
->
brow
->
ctx
);
brow_SelectClear
(
tblnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
tblnav
->
brow
->
ctx
,
object
);
brow_SelectInsert
(
tblnav
->
brow
->
ctx
,
object
);
...
@@ -309,8 +337,12 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -309,8 +337,12 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
item
);
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
switch
(
item
->
type
)
{
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_TreeLocal
:
((
ItemLocal
*
)
item
)
->
open_attributes
(
tblnav
,
0
,
0
);
((
ItemLocal
*
)
item
)
->
open_attributes
(
tblnav
,
0
,
0
);
break
;
break
;
case
tblnav_eItemType_TreeNode
:
((
ItemTreeNode
*
)
item
)
->
open_children
(
tblnav
,
0
,
0
);
break
;
default:
default:
;
;
}
}
...
@@ -321,9 +353,14 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -321,9 +353,14 @@ static int tblnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
switch
(
item
->
type
)
{
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_TreeLocal
:
((
ItemLocal
*
)
item
)
->
open_attributes
(
tblnav
,
((
ItemLocal
*
)
item
)
->
open_attributes
(
tblnav
,
event
->
object
.
x
,
event
->
object
.
y
);
event
->
object
.
x
,
event
->
object
.
y
);
break
;
break
;
case
tblnav_eItemType_TreeNode
:
((
ItemTreeNode
*
)
item
)
->
open_children
(
tblnav
,
event
->
object
.
x
,
event
->
object
.
y
);
break
;
default:
default:
;
;
}
}
...
@@ -378,14 +415,38 @@ void TblNavBrow::create_nodeclasses()
...
@@ -378,14 +415,38 @@ void TblNavBrow::create_nodeclasses()
}
}
int
TblNav
::
create_items
()
void
TblNav
::
show_list
()
{
list_layout
=
1
;
brow_DeleteAll
(
brow
->
ctx
);
create_items
();
}
void
TblNav
::
show_tree
()
{
list_layout
=
0
;
brow_DeleteAll
(
brow
->
ctx
);
create_items
();
}
int
TblNav
::
create_items
()
{
{
int
i
;
int
i
;
brow_SetNodraw
(
brow
->
ctx
);
brow_SetNodraw
(
brow
->
ctx
);
for
(
i
=
0
;
i
<
item_cnt
;
i
++
)
{
if
(
list_layout
)
{
new
ItemLocal
(
this
,
&
itemlist
[
i
],
NULL
,
flow_eDest_IntoLast
);
for
(
i
=
0
;
i
<
item_cnt
;
i
++
)
{
new
ItemLocal
(
this
,
&
itemlist
[
i
],
NULL
,
flow_eDest_IntoLast
);
}
}
else
{
for
(
int
idx
=
1
;
idx
;
idx
=
tree
[
idx
].
fws
)
{
if
(
tree
[
idx
].
item
)
new
ItemTreeLocal
(
this
,
tree
[
idx
].
item
,
idx
,
NULL
,
flow_eDest_IntoLast
);
else
new
ItemTreeNode
(
this
,
tree
[
idx
].
sname
,
idx
,
NULL
,
flow_eDest_IntoLast
);
}
}
}
brow_ResetNodraw
(
brow
->
ctx
);
brow_ResetNodraw
(
brow
->
ctx
);
brow_Redraw
(
brow
->
ctx
,
0
);
brow_Redraw
(
brow
->
ctx
,
0
);
...
@@ -449,6 +510,8 @@ int TblNav::init_brow_cb( FlowCtx *fctx, void *client_data)
...
@@ -449,6 +510,8 @@ int TblNav::init_brow_cb( FlowCtx *fctx, void *client_data)
tblnav
->
brow
->
brow_setup
();
tblnav
->
brow
->
brow_setup
();
tblnav
->
brow
->
create_nodeclasses
();
tblnav
->
brow
->
create_nodeclasses
();
tblnav
->
build_tree
();
// Create the root items
// Create the root items
tblnav
->
create_items
();
tblnav
->
create_items
();
...
@@ -476,6 +539,7 @@ int TblNav::get_select( sevcli_sHistItem **hi)
...
@@ -476,6 +539,7 @@ int TblNav::get_select( sevcli_sHistItem **hi)
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
item
);
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
switch
(
item
->
type
)
{
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_TreeLocal
:
*
hi
=
&
item
->
item
;
*
hi
=
&
item
->
item
;
return
1
;
return
1
;
default:
;
default:
;
...
@@ -484,8 +548,75 @@ int TblNav::get_select( sevcli_sHistItem **hi)
...
@@ -484,8 +548,75 @@ int TblNav::get_select( sevcli_sHistItem **hi)
}
}
//
// Get zoom
//
void
TblNav
::
get_zoom
(
double
*
zoom_factor
)
{
brow_GetZoom
(
brow
->
ctx
,
zoom_factor
);
}
//
// Zoom
//
void
TblNav
::
zoom
(
double
zoom_factor
)
{
brow_Zoom
(
brow
->
ctx
,
zoom_factor
);
}
//
// Return to base zoom factor
//
void
TblNav
::
unzoom
()
{
brow_UnZoom
(
brow
->
ctx
);
}
void
TblNav
::
delete_item
(
sevcli_sHistItem
*
hi
)
{
brow_tNode
*
node_list
;
int
node_count
;
ItemBase
*
baseitem
;
brow_GetObjectList
(
brow
->
ctx
,
&
node_list
,
&
node_count
);
// Delete in tree
for
(
int
i
=
1
;
i
<
(
int
)
tree
.
size
();
i
++
)
{
if
(
tree
[
i
].
deleted
)
continue
;
if
(
tree
[
i
].
item
&&
cdh_ObjidIsEqual
(
tree
[
i
].
item
->
oid
,
hi
->
oid
)
&&
strcmp
(
tree
[
i
].
item
->
aname
,
hi
->
aname
)
==
0
)
{
tree
[
i
].
deleted
=
1
;
}
}
// Delete node if visible
brow_GetObjectList
(
brow
->
ctx
,
&
node_list
,
&
node_count
);
int
found
=
0
;
for
(
int
i
=
0
;
i
<
node_count
;
i
++
)
{
brow_GetUserData
(
node_list
[
i
],
(
void
**
)
&
baseitem
);
switch
(
baseitem
->
type
)
{
case
tblnav_eItemType_Local
:
case
tblnav_eItemType_TreeLocal
:
{
ItemLocal
*
item
=
(
ItemLocal
*
)
baseitem
;
if
(
cdh_ObjidIsEqual
(
hi
->
oid
,
item
->
item
.
oid
)
&&
strcmp
(
hi
->
aname
,
item
->
item
.
aname
)
==
0
)
{
brow_DeleteNode
(
brow
->
ctx
,
item
->
node
);
found
=
1
;
}
break
;
}
default:
;
}
if
(
found
)
break
;
}
}
ItemLocal
::
ItemLocal
(
TblNav
*
tblnav
,
sevcli_sHistItem
*
xitem
,
ItemLocal
::
ItemLocal
(
TblNav
*
tblnav
,
sevcli_sHistItem
*
xitem
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
item
(
*
xitem
)
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
tblnav_eItemType_Local
),
item
(
*
xitem
)
{
{
type
=
tblnav_eItemType_Local
;
type
=
tblnav_eItemType_Local
;
pwr_tAName
aname
;
pwr_tAName
aname
;
...
@@ -590,10 +721,9 @@ int ItemLocal::close( TblNav *tblnav, double x, double y)
...
@@ -590,10 +721,9 @@ int ItemLocal::close( TblNav *tblnav, double x, double y)
}
}
ItemLocalAttr
::
ItemLocalAttr
(
TblNav
*
tblnav
,
char
*
name
,
char
*
value
,
ItemLocalAttr
::
ItemLocalAttr
(
TblNav
*
tblnav
,
char
*
name
,
char
*
value
,
brow_tNode
dest
,
flow_eDest
dest_code
)
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
tblnav_eItemType_LocalAttr
)
{
{
type
=
tblnav_eItemType_LocalAttr
;
brow_CreateNode
(
tblnav
->
brow
->
ctx
,
"LocalItemAttr"
,
tblnav
->
brow
->
nc_attr
,
brow_CreateNode
(
tblnav
->
brow
->
ctx
,
"LocalItemAttr"
,
tblnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
...
@@ -603,3 +733,185 @@ ItemLocalAttr::ItemLocalAttr( TblNav *tblnav, char *name, char *value,
...
@@ -603,3 +733,185 @@ ItemLocalAttr::ItemLocalAttr( TblNav *tblnav, char *name, char *value,
brow_SetAnnotation
(
node
,
1
,
value
,
strlen
(
value
));
brow_SetAnnotation
(
node
,
1
,
value
,
strlen
(
value
));
}
}
ItemTreeLocal
::
ItemTreeLocal
(
TblNav
*
tblnav
,
sevcli_sHistItem
*
xitem
,
int
index
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemLocal
(
tblnav
,
xitem
,
dest
,
dest_code
),
idx
(
index
)
{
pwr_tAName
aname
;
char
*
s
;
type
=
tblnav_eItemType_TreeLocal
;
if
((
s
=
strrchr
(
item
.
oname
,
'-'
)))
strcpy
(
aname
,
s
+
1
);
else
strcpy
(
aname
,
item
.
oname
);
strcat
(
aname
,
"."
);
strcat
(
aname
,
item
.
aname
);
brow_SetAnnotation
(
node
,
0
,
aname
,
strlen
(
aname
));
}
ItemTreeNode
::
ItemTreeNode
(
TblNav
*
tblnav
,
char
*
name
,
int
index
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
tblnav_eItemType_TreeNode
),
idx
(
index
)
{
brow_CreateNode
(
tblnav
->
brow
->
ctx
,
"TreeNode"
,
tblnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
if
(
tblnav
->
tree
[
idx
].
fch
)
brow_SetAnnotPixmap
(
node
,
0
,
tblnav
->
brow
->
pixmap_map
);
else
brow_SetAnnotPixmap
(
node
,
0
,
tblnav
->
brow
->
pixmap_leaf
);
brow_SetAnnotation
(
node
,
0
,
name
,
strlen
(
name
));
}
int
ItemTreeNode
::
open_children
(
TblNav
*
tblnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
)
&
tblnav_mOpen_Children
)
{
// Attributes is open, close
brow_SetNodraw
(
tblnav
->
brow
->
ctx
);
brow_CloseNode
(
tblnav
->
brow
->
ctx
,
node
);
brow_ResetOpen
(
node
,
tblnav_mOpen_Children
);
brow_RemoveAnnotPixmap
(
node
,
1
);
brow_ResetNodraw
(
tblnav
->
brow
->
ctx
);
brow_Redraw
(
tblnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
tblnav
->
brow
->
ctx
);
for
(
int
i
=
tblnav
->
tree
[
idx
].
fch
;
i
;
i
=
tblnav
->
tree
[
i
].
fws
)
{
if
(
tblnav
->
tree
[
i
].
deleted
)
continue
;
if
(
tblnav
->
tree
[
i
].
item
)
new
ItemTreeLocal
(
tblnav
,
tblnav
->
tree
[
i
].
item
,
i
,
node
,
flow_eDest_IntoLast
);
else
new
ItemTreeNode
(
tblnav
,
tblnav
->
tree
[
i
].
sname
,
i
,
node
,
flow_eDest_IntoLast
);
}
brow_SetOpen
(
node
,
tblnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
1
,
tblnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
tblnav
->
brow
->
ctx
);
brow_Redraw
(
tblnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
int
ItemTreeNode
::
close
(
TblNav
*
tblnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
if
(
brow_IsOpen
(
node
)
&
tblnav_mOpen_Children
)
{
// Children is open, close
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
brow_SetNodraw
(
tblnav
->
brow
->
ctx
);
brow_CloseNode
(
tblnav
->
brow
->
ctx
,
node
);
brow_ResetOpen
(
node
,
tblnav_mOpen_All
);
brow_ResetNodraw
(
tblnav
->
brow
->
ctx
);
brow_Redraw
(
tblnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
void
TblNav
::
build_tree
()
{
pwr_tObjName
name_array
[
24
];
pwr_tAName
aname
;
int
seg
;
for
(
int
i
=
0
;
i
<
item_cnt
;
i
++
)
{
TblTreeNode
n
;
strcpy
(
aname
,
itemlist
[
i
].
oname
);
strcat
(
aname
,
"."
);
strcat
(
aname
,
itemlist
[
i
].
aname
);
seg
=
dcli_parse
(
aname
,
"-"
,
""
,
(
char
*
)
name_array
,
sizeof
(
name_array
)
/
sizeof
(
name_array
[
0
]),
sizeof
(
name_array
[
0
]),
0
);
if
(
tree
.
size
()
==
0
)
{
// First item
TblTreeNode
n0
;
strcpy
(
n0
.
sname
,
"nonode"
);
tree
.
push_back
(
n0
);
for
(
int
j
=
0
;
j
<
seg
;
j
++
)
{
TblTreeNode
n
;
n
.
fth
=
j
;
tree
[
j
].
fch
=
j
+
1
;
strcpy
(
n
.
sname
,
name_array
[
j
]);
if
(
j
==
seg
-
1
)
n
.
item
=
&
itemlist
[
i
];
tree
.
push_back
(
n
);
}
}
else
{
int
idx
=
1
;
int
last
=
idx
;
for
(
int
j
=
0
;
j
<
seg
;
j
++
)
{
int
found
=
0
;
while
(
idx
)
{
last
=
idx
;
if
(
strcmp
(
tree
[
idx
].
sname
,
name_array
[
j
])
==
0
)
{
found
=
1
;
break
;
}
idx
=
tree
[
idx
].
fws
;
}
if
(
!
found
)
{
TblTreeNode
n
;
strcpy
(
n
.
sname
,
name_array
[
j
]);
n
.
fth
=
tree
[
last
].
fth
;
n
.
bws
=
last
;
tree
[
last
].
fws
=
tree
.
size
();
if
(
j
==
seg
-
1
)
n
.
item
=
&
itemlist
[
i
];
tree
.
push_back
(
n
);
for
(
int
k
=
j
+
1
;
k
<
seg
;
k
++
)
{
TblTreeNode
n
;
n
.
fth
=
tree
.
size
()
-
1
;
if
(
tree
[
n
.
fth
].
fch
==
0
)
tree
[
n
.
fth
].
fch
=
tree
.
size
();
strcpy
(
n
.
sname
,
name_array
[
k
]);
if
(
k
==
seg
-
1
)
n
.
item
=
&
itemlist
[
i
];
tree
.
push_back
(
n
);
}
break
;
}
if
(
tree
[
idx
].
fch
==
0
)
{
TblTreeNode
n
;
strcpy
(
n
.
sname
,
name_array
[
j
]);
n
.
fth
=
tree
[
last
].
fth
;
n
.
bws
=
last
;
tree
[
last
].
fws
=
tree
.
size
();
if
(
j
==
seg
-
1
)
n
.
item
=
&
itemlist
[
i
];
tree
.
push_back
(
n
);
for
(
int
k
=
j
+
1
;
k
<
seg
;
k
++
)
{
TblTreeNode
n
;
n
.
fth
=
tree
.
size
()
-
1
;
if
(
tree
[
n
.
fth
].
fch
==
0
)
tree
[
n
.
fth
].
fch
=
tree
.
size
();
strcpy
(
n
.
sname
,
name_array
[
k
]);
if
(
k
==
seg
-
1
)
n
.
item
=
&
itemlist
[
i
];
tree
.
push_back
(
n
);
}
break
;
}
idx
=
tree
[
idx
].
fch
;
last
=
idx
;
}
}
}
}
sev/exe/sev_xtt/src/xtt_tblnav.h
View file @
7a20e851
/*
/*
* Proview $Id: xtt_tblnav.h,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: xtt_tblnav.h,v 1.
2 2008-09-05 08:38:58
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
...
@@ -22,10 +22,17 @@
...
@@ -22,10 +22,17 @@
/* xtt_attrnav.h -- Sev Table Viewer */
/* xtt_attrnav.h -- Sev Table Viewer */
#include <fstream.h>
#include <vector.h>
#ifndef pwr_h
#ifndef pwr_h
# include "pwr.h"
# include "pwr.h"
#endif
#endif
#ifndef pwr_privilege_h
#include "pwr_privilege.h"
#endif
#ifndef flow_h
#ifndef flow_h
#include "flow.h"
#include "flow.h"
#endif
#endif
...
@@ -45,15 +52,31 @@
...
@@ -45,15 +52,31 @@
typedef
enum
{
typedef
enum
{
tblnav_eItemType_Local
,
tblnav_eItemType_Local
,
tblnav_eItemType_LocalAttr
tblnav_eItemType_LocalAttr
,
tblnav_eItemType_TreeLocal
,
tblnav_eItemType_TreeNode
}
tblnav_eItemType
;
}
tblnav_eItemType
;
typedef
enum
{
typedef
enum
{
tblnav_mOpen_All
=
~
0
,
tblnav_mOpen_All
=
~
0
,
tblnav_mOpen_Children
=
1
<<
0
,
tblnav_mOpen_Attributes
=
1
<<
1
tblnav_mOpen_Attributes
=
1
<<
1
}
tblnav_mOpen
;
}
tblnav_mOpen
;
class
TblTreeNode
{
public:
TblTreeNode
()
:
fth
(
0
),
fch
(
0
),
fws
(
0
),
bws
(
0
),
item
(
0
),
deleted
(
0
)
{
strcpy
(
sname
,
""
);}
int
fth
;
int
fch
;
int
fws
;
int
bws
;
char
sname
[
80
];
sevcli_sHistItem
*
item
;
int
deleted
;
};
//! Class for handling of brow.
//! Class for handling of brow.
class
TblNavBrow
{
class
TblNavBrow
{
public:
public:
...
@@ -91,35 +114,79 @@ class TblNav {
...
@@ -91,35 +114,79 @@ class TblNav {
sevcli_sHistItem
*
itemlist
;
sevcli_sHistItem
*
itemlist
;
int
item_cnt
;
int
item_cnt
;
void
(
*
message_cb
)(
void
*
,
char
,
char
*
);
void
(
*
message_cb
)(
void
*
,
char
,
char
*
);
int
(
*
is_authorized_cb
)(
void
*
,
unsigned
int
,
int
);
vector
<
TblTreeNode
>
tree
;
int
list_layout
;
void
print
(
char
*
filename
);
int
is_authorized
(
unsigned
int
access
=
pwr_mAccess_AllSev
,
int
msg
=
1
);
int
create_items
();
int
create_items
();
void
build_tree
();
int
get_select
(
sevcli_sHistItem
**
hi
);
int
get_select
(
sevcli_sHistItem
**
hi
);
void
get_zoom
(
double
*
zoom_factor
);
void
zoom
(
double
zoom_factor
);
void
unzoom
();
void
show_tree
();
void
show_list
();
void
delete_item
(
sevcli_sHistItem
*
hi
);
virtual
void
message
(
char
sev
,
char
*
text
);
virtual
void
message
(
char
sev
,
char
*
text
);
virtual
void
set_inputfocus
()
{}
virtual
void
set_inputfocus
()
{}
static
int
init_brow_cb
(
FlowCtx
*
fctx
,
void
*
client_data
);
static
int
init_brow_cb
(
FlowCtx
*
fctx
,
void
*
client_data
);
};
};
class
ItemBase
{
public:
ItemBase
(
tblnav_eItemType
t
)
:
type
(
t
)
{}
virtual
~
ItemBase
()
{}
tblnav_eItemType
type
;
virtual
int
close
(
TblNav
*
tblnav
,
double
x
,
double
y
)
{
return
1
;}
};
//! Item for a normal attribute.
//! Item for a normal attribute.
class
ItemLocal
{
class
ItemLocal
:
public
ItemBase
{
public:
public:
ItemLocal
(
TblNav
*
tblnav
,
sevcli_sHistItem
*
item
,
brow_tNode
dest
,
flow_eDest
dest_code
);
ItemLocal
(
TblNav
*
tblnav
,
sevcli_sHistItem
*
item
,
brow_tNode
dest
,
flow_eDest
dest_code
);
virtual
~
ItemLocal
()
{}
sevcli_sHistItem
item
;
sevcli_sHistItem
item
;
tblnav_eItemType
type
;
brow_tNode
node
;
brow_tNode
node
;
int
open_attributes
(
TblNav
*
tblnav
,
double
x
,
double
y
);
int
open_attributes
(
TblNav
*
tblnav
,
double
x
,
double
y
);
int
close
(
TblNav
*
tblnav
,
double
x
,
double
y
);
int
close
(
TblNav
*
tblnav
,
double
x
,
double
y
);
};
};
class
ItemLocalAttr
{
class
ItemLocalAttr
:
public
ItemBase
{
public:
public:
ItemLocalAttr
(
TblNav
*
tblnav
,
char
*
iname
,
char
*
ivalue
,
brow_tNode
dest
,
flow_eDest
dest_code
);
ItemLocalAttr
(
TblNav
*
tblnav
,
char
*
iname
,
char
*
ivalue
,
brow_tNode
dest
,
flow_eDest
dest_code
);
virtual
~
ItemLocalAttr
()
{}
sevcli_sHistItem
item
;
sevcli_sHistItem
item
;
tblnav_eItemType
type
;
brow_tNode
node
;
brow_tNode
node
;
};
};
//! Item for a normal attribute.
class
ItemTreeLocal
:
public
ItemLocal
{
public:
ItemTreeLocal
(
TblNav
*
tblnav
,
sevcli_sHistItem
*
item
,
int
index
,
brow_tNode
dest
,
flow_eDest
dest_code
);
virtual
~
ItemTreeLocal
()
{}
int
idx
;
};
//! Item for a normal attribute.
class
ItemTreeNode
:
public
ItemBase
{
public:
ItemTreeNode
(
TblNav
*
tblnav
,
char
*
name
,
int
index
,
brow_tNode
dest
,
flow_eDest
dest_code
);
virtual
~
ItemTreeNode
()
{}
brow_tNode
node
;
int
idx
;
int
open_children
(
TblNav
*
tblnav
,
double
x
,
double
y
);
int
close
(
TblNav
*
tblnav
,
double
x
,
double
y
);
};
#endif
#endif
sev/lib/sev/src/sev_db.h
View file @
7a20e851
/*
/*
* Proview $Id: sev_db.h,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: sev_db.h,v 1.
2 2008-09-05 08:38:58
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
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
class
sev_item
{
class
sev_item
{
public:
public:
sev_item
()
{}
sev_item
()
:
deleted
(
0
)
{}
unsigned
int
id
;
unsigned
int
id
;
char
tablename
[
256
];
char
tablename
[
256
];
pwr_tOid
oid
;
pwr_tOid
oid
;
...
@@ -43,6 +43,7 @@ class sev_item {
...
@@ -43,6 +43,7 @@ class sev_item {
pwr_tString80
description
;
pwr_tString80
description
;
pwr_tString16
unit
;
pwr_tString16
unit
;
pwr_tFloat32
scantime
;
pwr_tFloat32
scantime
;
int
deleted
;
};
};
...
@@ -60,6 +61,7 @@ class sev_db {
...
@@ -60,6 +61,7 @@ class sev_db {
pwr_tDeltaTime
storagetime
,
pwr_eType
type
,
unsigned
int
size
,
pwr_tDeltaTime
storagetime
,
pwr_eType
type
,
unsigned
int
size
,
char
*
description
,
char
*
unit
,
pwr_tFloat32
scantime
,
unsigned
int
*
idx
)
char
*
description
,
char
*
unit
,
pwr_tFloat32
scantime
,
unsigned
int
*
idx
)
{
return
0
;}
{
return
0
;}
virtual
int
delete_item
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
)
{
return
0
;}
virtual
int
store_value
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_eType
type
,
virtual
int
store_value
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_eType
type
,
pwr_tTime
time
,
void
*
buf
,
unsigned
int
size
)
{
return
0
;}
pwr_tTime
time
,
void
*
buf
,
unsigned
int
size
)
{
return
0
;}
virtual
int
get_values
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_eType
type
,
virtual
int
get_values
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_eType
type
,
...
...
sev/lib/sev/src/sev_dbms.cpp
View file @
7a20e851
/*
/*
* Proview $Id: sev_dbms.cpp,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: sev_dbms.cpp,v 1.
2 2008-09-05 08:38:58
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
...
@@ -446,6 +446,22 @@ int sev_dbms::create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eTy
...
@@ -446,6 +446,22 @@ int sev_dbms::create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eTy
return
1
;
return
1
;
}
}
int
sev_dbms
::
delete_table
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
)
{
char
query
[
200
];
sprintf
(
query
,
"drop table %s;"
,
oid_to_table
(
oid
,
aname
));
int
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
printf
(
"Delete table: %s
\n
"
,
mysql_error
(
m_env
->
con
()));
*
sts
=
SEV__DBERROR
;
return
0
;
}
return
1
;
}
int
sev_dbms
::
store_item
(
pwr_tStatus
*
sts
,
char
*
tablename
,
pwr_tOid
oid
,
char
*
oname
,
int
sev_dbms
::
store_item
(
pwr_tStatus
*
sts
,
char
*
tablename
,
pwr_tOid
oid
,
char
*
oname
,
char
*
aname
,
pwr_tDeltaTime
storagetime
,
pwr_eType
vtype
,
char
*
aname
,
pwr_tDeltaTime
storagetime
,
pwr_eType
vtype
,
unsigned
int
vsize
,
char
*
description
,
char
*
unit
,
pwr_tFloat32
scantime
)
unsigned
int
vsize
,
char
*
description
,
char
*
unit
,
pwr_tFloat32
scantime
)
...
@@ -473,6 +489,23 @@ int sev_dbms::store_item( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char
...
@@ -473,6 +489,23 @@ int sev_dbms::store_item( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char
return
1
;
return
1
;
}
}
int
sev_dbms
::
remove_item
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
)
{
char
query
[
800
];
sprintf
(
query
,
"delete from items where vid = %u and oix = %u and aname = '%s';"
,
oid
.
vid
,
oid
.
oix
,
aname
);
int
rc
=
mysql_query
(
m_env
->
con
(),
query
);
if
(
rc
)
{
printf
(
"Remove item: %s
\n
"
,
mysql_error
(
m_env
->
con
()));
*
sts
=
SEV__DBERROR
;
return
0
;
}
*
sts
=
SEV__SUCCESS
;
return
1
;
}
int
sev_dbms
::
get_items
(
pwr_tStatus
*
sts
)
int
sev_dbms
::
get_items
(
pwr_tStatus
*
sts
)
{
{
m_items
.
clear
();
m_items
.
clear
();
...
@@ -761,6 +794,9 @@ int sev_dbms::check_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *ana
...
@@ -761,6 +794,9 @@ int sev_dbms::check_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *ana
timestr
[
19
]
=
0
;
timestr
[
19
]
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
m_items
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
m_items
.
size
();
i
++
)
{
if
(
m_items
[
i
].
deleted
)
continue
;
if
(
cdh_ObjidIsEqual
(
oid
,
m_items
[
i
].
oid
)
&&
if
(
cdh_ObjidIsEqual
(
oid
,
m_items
[
i
].
oid
)
&&
cdh_NoCaseStrcmp
(
aname
,
m_items
[
i
].
aname
)
==
0
)
{
cdh_NoCaseStrcmp
(
aname
,
m_items
[
i
].
aname
)
==
0
)
{
char
query
[
400
];
char
query
[
400
];
...
@@ -830,6 +866,31 @@ int sev_dbms::add_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname
...
@@ -830,6 +866,31 @@ int sev_dbms::add_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname
return
1
;
return
1
;
}
}
int
sev_dbms
::
delete_item
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
)
{
char
tablename
[
256
];
strcpy
(
tablename
,
oid_to_table
(
oid
,
aname
));
remove_item
(
sts
,
oid
,
aname
);
if
(
ODD
(
*
sts
))
delete_table
(
sts
,
oid
,
aname
);
if
(
ODD
(
*
sts
))
{
for
(
int
i
=
0
;
i
<
(
int
)
m_items
.
size
();
i
++
)
{
if
(
m_items
[
i
].
deleted
)
continue
;
if
(
cdh_ObjidIsEqual
(
m_items
[
i
].
oid
,
oid
)
&&
cdh_NoCaseStrcmp
(
m_items
[
i
].
aname
,
aname
)
==
0
)
{
m_items
[
i
].
deleted
=
1
;
break
;
}
}
}
return
1
;
}
int
sev_dbms
::
delete_old_data
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_tTime
limit
)
int
sev_dbms
::
delete_old_data
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_tTime
limit
)
{
{
char
query
[
300
];
char
query
[
300
];
...
...
sev/lib/sev/src/sev_dbms.h
View file @
7a20e851
/*
/*
* Proview $Id: sev_dbms.h,v 1.
1 2008-07-17 11:18:31
claes Exp $
* Proview $Id: sev_dbms.h,v 1.
2 2008-09-05 08:38:58
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
...
@@ -115,12 +115,15 @@ class sev_dbms : public sev_db {
...
@@ -115,12 +115,15 @@ class sev_dbms : public sev_db {
pwr_tFloat32
scantime
,
pwr_tTime
*
starttime
,
pwr_tTime
*
endtime
,
pwr_tFloat32
scantime
,
pwr_tTime
*
starttime
,
pwr_tTime
*
endtime
,
int
maxsize
,
pwr_tTime
**
tbuf
,
void
**
vbuf
,
unsigned
int
*
bsize
);
int
maxsize
,
pwr_tTime
**
tbuf
,
void
**
vbuf
,
unsigned
int
*
bsize
);
int
delete_old_data
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_tTime
limit
);
int
delete_old_data
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_tTime
limit
);
int
delete_item
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
);
int
get_items
(
pwr_tStatus
*
sts
);
int
get_items
(
pwr_tStatus
*
sts
);
int
create_table
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_eType
type
,
unsigned
int
size
);
int
create_table
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
,
pwr_eType
type
,
unsigned
int
size
);
int
delete_table
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
);
int
store_item
(
pwr_tStatus
*
sts
,
char
*
tabelname
,
pwr_tOid
oid
,
char
*
oname
,
char
*
aname
,
int
store_item
(
pwr_tStatus
*
sts
,
char
*
tabelname
,
pwr_tOid
oid
,
char
*
oname
,
char
*
aname
,
pwr_tDeltaTime
storagetime
,
pwr_eType
vtype
,
unsigned
int
vsize
,
pwr_tDeltaTime
storagetime
,
pwr_eType
vtype
,
unsigned
int
vsize
,
char
*
description
,
char
*
unit
,
pwr_tFloat32
scantime
);
char
*
description
,
char
*
unit
,
pwr_tFloat32
scantime
);
int
remove_item
(
pwr_tStatus
*
sts
,
pwr_tOid
oid
,
char
*
aname
);
char
*
oid_to_table
(
pwr_tOid
oid
,
char
*
aname
);
char
*
oid_to_table
(
pwr_tOid
oid
,
char
*
aname
);
char
*
pwrtype_to_type
(
pwr_eType
type
,
unsigned
int
size
);
char
*
pwrtype_to_type
(
pwr_eType
type
,
unsigned
int
size
);
static
int
timestr_to_time
(
char
*
tstr
,
pwr_tTime
*
ts
);
static
int
timestr_to_time
(
char
*
tstr
,
pwr_tTime
*
ts
);
...
...
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