Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
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
Libraries
asn1c
Commits
7b3713a8
Commit
7b3713a8
authored
Jul 03, 2005
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stricter encoding
parent
82d80390
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
skeletons/UTCTime.c
skeletons/UTCTime.c
+23
-20
No files found.
skeletons/UTCTime.c
View file @
7b3713a8
...
...
@@ -8,7 +8,7 @@
#include <time.h>
#include <errno.h>
#ifndef __
NO_ASN_TABL
E__
#ifndef __
ASN_INTERNAL_TEST_MOD
E__
/*
* UTCTime basic type description.
...
...
@@ -39,7 +39,7 @@ asn_TYPE_descriptor_t asn_DEF_UTCTime = {
0
/* No specifics */
};
#endif
/* __
NO_ASN_TABL
E__ */
#endif
/* __
ASN_INTERNAL_TEST_MOD
E__ */
/*
* Check that the time looks like the time.
...
...
@@ -62,36 +62,39 @@ UTCTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return
0
;
}
#ifndef __ASN_INTERNAL_TEST_MODE__
asn_enc_rval_t
UTCTime_encode_xer
(
asn_TYPE_descriptor_t
*
td
,
void
*
sptr
,
int
ilevel
,
enum
xer_encoder_flags_e
flags
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
OCTET_STRING_t
st
;
if
(
flags
&
XER_F_CANONICAL
)
{
char
buf
[
32
];
asn_enc_rval_t
rv
;
UTCTime_t
*
ut
;
struct
tm
tm
;
ssize_t
ret
;
errno
=
EPERM
;
if
(
asn_UT2time
((
UTCTime_t
*
)
sptr
,
&
tm
,
1
)
==
-
1
&&
errno
!=
EPERM
)
_ASN_ENCODE_FAILED
;
ret
=
snprintf
(
buf
,
sizeof
(
buf
),
"%02d%02d%02d%02d%02d%02dZ"
,
tm
.
tm_year
%
100
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
assert
(
ret
>
0
&&
ret
<
(
int
)
sizeof
(
buf
));
st
.
buf
=
(
uint8_t
*
)
buf
;
st
.
size
=
ret
;
sptr
=
&
st
;
}
return
OCTET_STRING_encode_xer_utf8
(
td
,
sptr
,
ilevel
,
flags
,
cb
,
app_key
);
/* Fractions are not allowed in UTCTime */
ut
=
asn_time2GT
(
0
,
0
,
1
);
if
(
!
ut
)
_ASN_ENCODE_FAILED
;
rv
=
OCTET_STRING_encode_xer_utf8
(
td
,
sptr
,
ilevel
,
flags
,
cb
,
app_key
);
OCTET_STRING_free
(
&
asn_DEF_UTCTime
,
ut
,
0
);
return
rv
;
}
else
{
return
OCTET_STRING_encode_xer_utf8
(
td
,
sptr
,
ilevel
,
flags
,
cb
,
app_key
);
}
}
#endif
/* __ASN_INTERNAL_TEST_MODE__ */
int
UTCTime_print
(
asn_TYPE_descriptor_t
*
td
,
const
void
*
sptr
,
int
ilevel
,
asn_app_consume_bytes_f
*
cb
,
void
*
app_key
)
{
...
...
@@ -110,7 +113,7 @@ UTCTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
return
(
cb
(
"<bad-value>"
,
11
,
app_key
)
<
0
)
?
-
1
:
0
;
ret
=
snprintf
(
buf
,
sizeof
(
buf
),
"%04d-%02d-%02d %02d:%02d%02d (GMT)"
,
"%04d-%02d-%02d %02d:%02d
:
%02d (GMT)"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
assert
(
ret
>
0
&&
ret
<
(
int
)
sizeof
(
buf
));
...
...
@@ -122,11 +125,11 @@ UTCTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
time_t
asn_UT2time
(
const
UTCTime_t
*
st
,
struct
tm
*
_tm
,
int
as_gmt
)
{
char
buf
[
17
+
2
];
/* "AAMMJJhhmmss+hhmm" = 17, + 2 = 19
*/
char
buf
[
24
];
/* "AAMMJJhhmmss+hhmm" + cushion
*/
GeneralizedTime_t
gt
;
if
(
!
st
||
!
st
->
buf
||
st
->
size
<
11
||
st
->
size
>
((
int
)
sizeof
(
buf
)
-
2
))
{
||
st
->
size
<
11
||
st
->
size
>
=
((
int
)
sizeof
(
buf
)
-
2
))
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
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