Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
76f2a671
Commit
76f2a671
authored
20 years ago
by
Benjamin Couturier
Browse files
Options
Downloads
Patches
Plain Diff
Store Csec error in a per thread buffer
parent
070f3924
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
security/Csec_errmsg.c
+34
-49
34 additions, 49 deletions
security/Csec_errmsg.c
with
34 additions
and
49 deletions
security/Csec_errmsg.c
+
34
−
49
View file @
76f2a671
...
...
@@ -15,60 +15,45 @@ static char sccsid[] = "@(#)Csec_errmsg.c,v 1.1 2004/01/12 10:31:40 CERN IT/ADC/
#include
"Csec.h"
/* Csec_seterrbuf - set receiving buffer for error messages */
/* Csec_errmsg - send error message to error buffer in per-thread structure */
int
DLL_DECL
Csec_seterrbuf
(
char
*
buffer
,
int
buflen
)
{
struct
Csec_api_thread_info
*
thip
;
if
(
Csec_apiinit
(
&
thip
))
return
(
-
1
);
thip
->
errbufp
=
buffer
;
thip
->
errbuflen
=
buflen
;
return
(
0
);
Csec_errmsg
(
char
*
func
,
char
*
msg
,
...)
{
va_list
args
;
int
save_errno
;
struct
Csec_api_thread_info
*
thip
;
int
funlen
=
0
;
save_errno
=
errno
;
if
(
Csec_apiinit
(
&
thip
))
return
(
-
1
);
va_start
(
args
,
msg
);
if
(
func
)
{
snprintf
(
thip
->
errbuf
,
ERRBUFSIZE
,
"%s: "
,
func
);
}
funlen
=
strlen
(
thip
->
errbuf
);
vsnprintf
(
thip
->
errbuf
+
funlen
,
ERRBUFSIZE
-
funlen
-
1
,
msg
,
args
);
thip
->
errbuf
[
ERRBUFSIZE
]
=
'\0'
;
Csec_trace
(
"ERROR"
,
"%s
\n
"
,
thip
->
errbuf
);
errno
=
save_errno
;
return
(
0
);
}
/* Csec_errmsg - send error message to user defined client buffer or to stderr */
int
DLL_DECL
Csec_errmsg
(
char
*
func
,
char
*
msg
,
...)
{
va_list
args
;
char
prtbuf
[
PRTBUFSZ
];
int
save_errno
;
struct
Csec_api_thread_info
*
thip
;
int
funlen
=
0
;
save_errno
=
errno
;
if
(
Csec_apiinit
(
&
thip
))
return
(
-
1
);
va_start
(
args
,
msg
);
if
(
func
)
snprintf
(
prtbuf
,
PRTBUFSZ
,
"%s: "
,
func
);
else
*
prtbuf
=
'\0'
;
funlen
=
strlen
(
prtbuf
);
/* Csec_errmsg - send error message to user defined client buffer or to stderr */
char
*
Csec_geterrmsg
()
{
vsnprintf
(
prtbuf
+
funlen
,
PRTBUFSZ
-
funlen
-
1
,
msg
,
args
);
prtbuf
[
PRTBUFSZ
]
=
'\0'
;
if
(
thip
->
errbufp
)
{
if
(
strlen
(
prtbuf
)
<
thip
->
errbuflen
)
{
strcpy
(
thip
->
errbufp
,
prtbuf
);
}
else
{
strncpy
(
thip
->
errbufp
,
prtbuf
,
thip
->
errbuflen
-
2
);
thip
->
errbufp
[
thip
->
errbuflen
-
2
]
=
'\n'
;
thip
->
errbufp
[
thip
->
errbuflen
-
1
]
=
'\0'
;
}
}
else
{
fprintf
(
stderr
,
"%s
\n
"
,
prtbuf
);
}
struct
Csec_api_thread_info
*
thip
;
if
(
Csec_apiinit
(
&
thip
))
return
NULL
;
return
thip
->
errbuf
;
Csec_trace
(
"ERROR"
,
"%s
\n
"
,
prtbuf
);
errno
=
save_errno
;
return
(
0
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment