Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Jaak Ristioja
OpenLDAP
Commits
702bdbf8
Commit
702bdbf8
authored
23 years ago
by
Pierangelo Masarati
Browse files
Options
Downloads
Patches
Plain Diff
added local time under 'lang' (lang-x-local)
parent
8cd8053d
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
servers/slapd/back-monitor/time.c
+69
-17
69 additions, 17 deletions
servers/slapd/back-monitor/time.c
with
69 additions
and
17 deletions
servers/slapd/back-monitor/time.c
+
69
−
17
View file @
702bdbf8
...
...
@@ -41,6 +41,9 @@
#include
"proto-slap.h"
#include
"back-monitor.h"
static
int
local_time
(
const
struct
tm
*
ztm
,
long
delta
,
char
*
buf
,
size_t
len
);
int
monitor_subsys_time_init
(
BackendDB
*
be
...
...
@@ -50,8 +53,8 @@ monitor_subsys_time_init(
Entry
*
e
,
*
e_tmp
,
*
e_time
;
struct
monitorentrypriv
*
mp
;
char
buf
[
1024
],
tmbuf
[
20
];
struct
tm
*
ltm
;
char
buf
[
1024
],
ztmbuf
[
20
],
l
tmbuf
[
20
];
struct
tm
*
ztm
,
*
ltm
;
assert
(
be
!=
NULL
);
...
...
@@ -80,16 +83,19 @@ monitor_subsys_time_init(
* Start
*/
ldap_pvt_thread_mutex_lock
(
&
gmtime_mutex
);
ltm
=
gmtime
(
&
starttime
);
strftime
(
tmbuf
,
sizeof
(
tmbuf
),
"%Y%m%d%H%M%SZ"
,
ltm
);
ztm
=
gmtime
(
&
starttime
);
strftime
(
ztmbuf
,
sizeof
(
ztmbuf
),
"%Y%m%d%H%M%SZ"
,
ztm
);
ltm
=
localtime
(
&
starttime
);
local_time
(
ltm
,
-
timezone
,
ltmbuf
,
sizeof
(
ltmbuf
)
);
ldap_pvt_thread_mutex_unlock
(
&
gmtime_mutex
);
snprintf
(
buf
,
sizeof
(
buf
),
"dn: cn=Start,%s
\n
"
SLAPD_MONITOR_OBJECTCLASSES
"cn: Start
\n
"
"description: %s"
,
"description: %s
\n
"
"description;lang-x-local: %s"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_dn
.
bv_val
,
tmbuf
);
ztmbuf
,
l
tmbuf
);
e
=
str2entry
(
buf
);
if
(
e
==
NULL
)
{
...
...
@@ -141,9 +147,10 @@ monitor_subsys_time_init(
"dn: cn=Current,%s
\n
"
SLAPD_MONITOR_OBJECTCLASSES
"cn: Current
\n
"
"description: %s"
,
"description: %s
\n
"
"description;lang-x-local: %s"
,
monitor_subsys
[
SLAPD_MONITOR_TIME
].
mss_dn
.
bv_val
,
tmbuf
);
ztmbuf
,
l
tmbuf
);
e
=
str2entry
(
buf
);
if
(
e
==
NULL
)
{
...
...
@@ -202,11 +209,12 @@ monitor_subsys_time_update(
Entry
*
e
)
{
char
tmbuf
[
20
];
struct
tm
*
ltm
;
char
ztmbuf
[
20
],
l
tmbuf
[
20
];
struct
tm
*
ztm
,
*
ltm
;
time_t
currenttime
;
struct
berval
bv
[
2
];
Attribute
*
a
;
static
AttributeDescription
*
ad_local
=
NULL
;
const
char
*
text
=
NULL
;
ber_len_t
len
;
static
int
init_start
=
0
;
...
...
@@ -227,21 +235,65 @@ monitor_subsys_time_update(
return
(
0
);
}
ldap_pvt_thread_mutex_lock
(
&
gmtime_mutex
);
ztm
=
gmtime
(
&
currenttime
);
strftime
(
ztmbuf
,
sizeof
(
ztmbuf
),
"%Y%m%d%H%M%SZ"
,
ztm
);
ltm
=
localtime
(
&
currenttime
);
local_time
(
ltm
,
-
timezone
,
ltmbuf
,
sizeof
(
ltmbuf
)
);
ldap_pvt_thread_mutex_unlock
(
&
gmtime_mutex
);
a
=
attr_find
(
e
->
e_attrs
,
monitor_ad_desc
);
if
(
a
==
NULL
)
{
return
(
-
1
);
}
len
=
strlen
(
ztmbuf
);
assert
(
len
==
a
->
a_vals
[
0
].
bv_len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
ztmbuf
,
len
);
ldap_pvt_thread_mutex_lock
(
&
gmtime_mutex
);
ltm
=
gmtime
(
&
currenttime
);
strftime
(
tmbuf
,
sizeof
(
tmbuf
),
"%Y%m%d%H%M%SZ"
,
ltm
);
ldap_pvt_thread_mutex_unlock
(
&
gmtime_mutex
);
if
(
ad_local
==
NULL
)
{
if
(
slap_str2ad
(
"description;lang-x-local"
,
&
ad_local
,
&
text
)
!=
LDAP_SUCCESS
)
{
return
(
-
1
);
}
}
a
=
attr_find
(
e
->
e_attrs
,
ad_local
);
if
(
a
==
NULL
)
{
return
(
-
1
);
}
len
=
strlen
(
tmbuf
);
len
=
strlen
(
l
tmbuf
);
assert
(
len
==
a
->
a_vals
[
0
].
bv_len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
tmbuf
,
len
);
AC_MEMCPY
(
a
->
a_vals
[
0
].
bv_val
,
l
tmbuf
,
len
);
return
(
0
);
}
/*
* assumes gmtime_mutex is locked
*/
static
int
local_time
(
const
struct
tm
*
ltm
,
long
delta
,
char
*
buf
,
size_t
len
)
{
char
*
p
;
if
(
len
<
20
)
{
return
-
1
;
}
strftime
(
buf
,
len
,
"%Y%m%d%H%M%S"
,
ltm
);
p
=
buf
+
14
;
if
(
delta
<
0
)
{
p
[
0
]
=
'-'
;
delta
=
-
delta
;
}
else
{
p
[
0
]
=
'+'
;
}
p
++
;
snprintf
(
p
,
len
-
15
,
"%02ld%02ld"
,
delta
/
3600
,
delta
%
3600
);
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