Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
JAliEn
JAliEn-ROOT
Commits
56d8ee3e
Commit
56d8ee3e
authored
Oct 15, 2019
by
Volodymyr Yurchenko
Browse files
Rename jclient variables
parent
d7a77725
Pipeline
#1154428
passed with stage
in 5 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/TJClientFile.cxx
View file @
56d8ee3e
...
...
@@ -7,144 +7,131 @@
using
std
::
ifstream
;
TJClientFile
::
TJClientFile
(
const
char
*
filepath
)
{
if
(
filepath
!=
NULL
)
{
this
->
isValid
=
loadFile
(
filepath
);
}
else
{
this
->
isValid
=
loadFile
(
getDefaultPath
());
}
if
(
filepath
!=
NULL
)
{
this
->
isValid
=
loadFile
(
filepath
);
}
else
{
this
->
isValid
=
loadFile
(
getDefaultPath
());
}
}
TString
TJClientFile
::
getDefaultPath
()
{
char
*
cUserId
=
new
char
[
10
];
sprintf
(
cUserId
,
"%d"
,
getuid
());
char
*
cUserId
=
new
char
[
10
];
sprintf
(
cUserId
,
"%d"
,
getuid
());
char
*
jclientFileLocation
=
new
char
[
100
];
sprintf
(
jclientFileLocation
,
"%s%s%s"
,
P_tmpdir
,
"/jclient_token_"
,
cUserId
);
defaultJClientPath
=
TString
(
jclientFileLocation
);
char
*
jclientFileLocation
=
new
char
[
100
];
sprintf
(
jclientFileLocation
,
"%s%s%s"
,
P_tmpdir
,
"/jclient_token_"
,
cUserId
);
defaultJClientPath
=
TString
(
jclientFileLocation
);
delete
[]
cUserId
;
delete
[]
jclientFileLocation
;
delete
[]
cUserId
;
delete
[]
jclientFileLocation
;
return
defaultJClientPath
;
return
defaultJClientPath
;
}
void
TJClientFile
::
setTmpdir
()
{
if
(
getenv
(
"TMPDIR"
)
!=
NULL
)
tmpdir
=
getenv
(
"TMPDIR"
);
else
if
(
getenv
(
"TMP"
)
!=
NULL
)
tmpdir
=
getenv
(
"TMP"
);
else
if
(
getenv
(
"TEMP"
)
!=
NULL
)
tmpdir
=
getenv
(
"TEMP"
);
else
tmpdir
=
P_tmpdir
;
if
(
getenv
(
"TMPDIR"
)
!=
NULL
)
tmpdir
=
getenv
(
"TMPDIR"
);
else
if
(
getenv
(
"TMP"
)
!=
NULL
)
tmpdir
=
getenv
(
"TMP"
);
else
if
(
getenv
(
"TEMP"
)
!=
NULL
)
tmpdir
=
getenv
(
"TEMP"
);
else
tmpdir
=
P_tmpdir
;
}
bool
TJClientFile
::
loadFile
(
const
char
*
filepath
)
{
if
(
filepath
==
NULL
)
{
return
false
;
}
if
(
filepath
==
NULL
)
{
return
false
;
}
ifstream
jclientFile
(
filepath
);
string
fileLine
;
ifstream
jclientFile
(
filepath
);
string
fileLine
;
bool
result
=
true
;
bool
result
=
true
;
if
(
jclientFile
.
is_open
())
if
(
jclientFile
.
is_open
())
{
while
(
getline
(
jclientFile
,
fileLine
))
while
(
getline
(
jclientFile
,
fileLine
))
{
if
(
gDebug
>
1
)
Info
(
"TJAlien"
,
"Token file line: %s"
,
fileLine
.
c_str
());
if
(
gDebug
>
1
)
Info
(
"TJAlien"
,
"Token file line: %s"
,
fileLine
.
c_str
());
TString
sLine
=
fileLine
;
TObjArray
*
arr
=
sLine
.
Tokenize
(
"= "
);
TString
sLine
=
fileLine
;
TObjArray
*
arr
=
sLine
.
Tokenize
(
"= "
);
if
(
arr
->
GetEntries
()
==
2
)
if
(
arr
->
GetEntries
()
==
2
)
{
TObjString
*
a
=
(
TObjString
*
)
arr
->
At
(
0
);
TObjString
*
b
=
(
TObjString
*
)
arr
->
At
(
1
);
TObjString
*
a
=
(
TObjString
*
)
arr
->
At
(
0
);
TObjString
*
b
=
(
TObjString
*
)
arr
->
At
(
1
);
TString
sKey
=
a
->
GetString
();
TString
sValue
=
b
->
GetString
();
TString
sKey
=
a
->
GetString
();
TString
sValue
=
b
->
GetString
();
if
(
gDebug
>
1
)
Info
(
"TJAlien"
,
"
\"
%s
\"
=
\"
%s
\"
"
,
sKey
.
Data
(),
sValue
.
Data
());
if
(
gDebug
>
1
)
Info
(
"TJAlien"
,
"
\"
%s
\"
=
\"
%s
\"
"
,
sKey
.
Data
(),
sValue
.
Data
());
if
(
sKey
.
EqualTo
(
"
Host
"
))
if
(
sKey
.
EqualTo
(
"
JALIEN_HOST
"
))
{
fHost
=
sValue
;
fHost
=
sValue
;
if
(
fHost
==
NULL
||
fHost
.
Length
()
==
0
)
if
(
fHost
==
nullptr
||
fHost
.
Length
()
==
0
)
{
Error
(
"TJAlien"
,
"JAliEn connection host field empty"
);
result
=
false
;
Error
(
"TJAlien"
,
"JAliEn connection host field empty"
);
result
=
false
;
delete
arr
;
break
;
}
}
if
(
sKey
.
EqualTo
(
"Port"
))
{
fPort
=
sValue
.
Atoi
();
}
if
(
sKey
.
EqualTo
(
"WSPort"
))
if
(
sKey
.
EqualTo
(
"JALIEN_PORT"
))
{
fWS
Port
=
sValue
.
Atoi
();
f
Port
=
sValue
.
Atoi
();
}
if
(
sKey
.
EqualTo
(
"
Home
"
))
if
(
sKey
.
EqualTo
(
"
JALIEN_WSPORT
"
))
{
fHome
=
sValue
;
}
fWSPort
=
sValue
.
Atoi
();
if
(
sKey
.
EqualTo
(
"Usercert"
))
{
sUsercert
=
sValue
;
if
(
fWSPort
==
0
)
{
Error
(
"TJAlien"
,
"JAliEn connection port field empty or misspelled"
);
result
=
false
;
delete
arr
;
break
;
}
}
if
(
sKey
.
EqualTo
(
"
Userkey
"
))
if
(
sKey
.
EqualTo
(
"
JALIEN_HOME
"
))
{
sUserkey
=
sValue
;
fHome
=
sValue
;
}
if
(
sKey
.
EqualTo
(
"
User
"
))
if
(
sKey
.
EqualTo
(
"
JALIEN_USER
"
))
{
fUser
=
sValue
;
if
(
fUser
==
NULL
||
fUser
.
Length
()
==
0
)
{
if
(
gDebug
>
1
)
Error
(
"TJAlien"
,
"JAliEn connection user field is empty"
);
result
=
false
;
}
fUser
=
sValue
;
}
if
(
sKey
.
EqualTo
(
"
Passwd
"
))
if
(
sKey
.
EqualTo
(
"
JALIEN_PASSWORD
"
))
{
fPw
=
sValue
;
if
(
fPw
==
NULL
||
fPw
.
Length
()
==
0
)
{
if
(
gDebug
>
1
)
Error
(
"TJAlien"
,
"JAliEn connection password field is empty"
);
result
=
false
;
}
fPw
=
sValue
;
}
}
else
else
{
if
(
gDebug
>
1
)
Error
(
"TJAlien"
,
"jclient file does not have "
if
(
gDebug
>
1
)
Error
(
"TJAlien"
,
"jclient file does not have "
"the correct structure (%d)"
,
arr
->
GetEntries
());
result
=
false
;
result
=
false
;
}
delete
arr
;
delete
arr
;
}
jclientFile
.
close
();
jclientFile
.
close
();
}
else
else
{
if
(
gDebug
>
1
)
Error
(
"TJAlien"
,
"Error while opening jclient file"
);
result
=
false
;
if
(
gDebug
>
1
)
Error
(
"TJAlien"
,
"Error while opening jclient file"
);
result
=
false
;
}
return
result
;
return
result
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment