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
72ec9097
Commit
72ec9097
authored
Jul 05, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduce intmax_t
parent
5c9c3426
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
118 deletions
+176
-118
skeletons/INTEGER.c
skeletons/INTEGER.c
+149
-101
skeletons/INTEGER.h
skeletons/INTEGER.h
+22
-12
skeletons/OBJECT_IDENTIFIER.c
skeletons/OBJECT_IDENTIFIER.c
+5
-5
No files found.
skeletons/INTEGER.c
View file @
72ec9097
This diff is collapsed.
Click to expand it.
skeletons/INTEGER.h
View file @
72ec9097
...
@@ -41,34 +41,44 @@ xer_type_decoder_f INTEGER_decode_xer;
...
@@ -41,34 +41,44 @@ xer_type_decoder_f INTEGER_decode_xer;
xer_type_encoder_f
INTEGER_encode_xer
;
xer_type_encoder_f
INTEGER_encode_xer
;
per_type_decoder_f
INTEGER_decode_uper
;
per_type_decoder_f
INTEGER_decode_uper
;
per_type_encoder_f
INTEGER_encode_uper
;
per_type_encoder_f
INTEGER_encode_uper
;
per_type_decoder_f
INTEGER_decode_aper
;
per_type_encoder_f
INTEGER_encode_aper
;
/***********************************
/***********************************
* Some handy conversion routines. *
* Some handy conversion routines. *
***********************************/
***********************************/
/*
/*
* Natiwe size-independent conversion of native integers to/from INTEGER.
* (l_size) is in bytes.
* Returns 0 if it was possible to convert, -1 otherwise.
* Returns 0 if it was possible to convert, -1 otherwise.
* -1/EINVAL: Mandatory argument missing
* -1/EINVAL: Mandatory argument missing
* -1/ERANGE: Value encoded is out of range for long representation
* -1/ERANGE: Value encoded is out of range for long representation
* -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()).
* -1/ENOMEM: Memory allocation failed (in asn_*2INTEGER()).
*/
int
asn_INTEGER2imax
(
const
INTEGER_t
*
i
,
intmax_t
*
l
);
int
asn_INTEGER2umax
(
const
INTEGER_t
*
i
,
uintmax_t
*
l
);
int
asn_imax2INTEGER
(
INTEGER_t
*
i
,
intmax_t
l
);
int
asn_umax2INTEGER
(
INTEGER_t
*
i
,
uintmax_t
l
);
/*
* Size-specific conversion helpers.
*/
*/
int
asn_INTEGER2long
(
const
INTEGER_t
*
i
,
long
*
l
);
int
asn_INTEGER2long
(
const
INTEGER_t
*
i
,
long
*
l
);
int
asn_INTEGER2ulong
(
const
INTEGER_t
*
i
,
unsigned
long
*
l
);
int
asn_INTEGER2ulong
(
const
INTEGER_t
*
i
,
unsigned
long
*
l
);
int
asn_long2INTEGER
(
INTEGER_t
*
i
,
long
l
);
int
asn_long2INTEGER
(
INTEGER_t
*
i
,
long
l
);
int
asn_ulong2INTEGER
(
INTEGER_t
*
i
,
unsigned
long
l
);
int
asn_ulong2INTEGER
(
INTEGER_t
*
i
,
unsigned
long
l
);
/* A
a reified version of strtol
(3) with nicer error reporting. */
/* A
version of strtol/strtoimax
(3) with nicer error reporting. */
enum
asn_strto
l
_result_e
{
enum
asn_strto
x
_result_e
{
ASN_STRTO
L_ERROR_RANGE
=
-
3
,
/* Input outside of numeric range for long typ
e */
ASN_STRTO
X_ERROR_RANGE
=
-
3
,
/* Input outside of supported numeric rang
e */
ASN_STRTO
L
_ERROR_INVAL
=
-
2
,
/* Invalid data encountered (e.g., "+-") */
ASN_STRTO
X
_ERROR_INVAL
=
-
2
,
/* Invalid data encountered (e.g., "+-") */
ASN_STRTO
L
_EXPECT_MORE
=
-
1
,
/* More data expected (e.g. "+") */
ASN_STRTO
X
_EXPECT_MORE
=
-
1
,
/* More data expected (e.g. "+") */
ASN_STRTO
L
_OK
=
0
,
/* Conversion succeded, number ends at (*end) */
ASN_STRTO
X
_OK
=
0
,
/* Conversion succeded, number ends at (*end) */
ASN_STRTO
L
_EXTRA_DATA
=
1
/* Conversion succeded, but the string has extra stuff */
ASN_STRTO
X
_EXTRA_DATA
=
1
/* Conversion succeded, but the string has extra stuff */
};
};
enum
asn_strtol_result_e
asn_strtol_lim
(
const
char
*
str
,
const
char
**
end
,
long
*
l
);
enum
asn_strtox_result_e
asn_strtol_lim
(
const
char
*
str
,
const
char
**
end
,
long
*
l
);
enum
asn_strtox_result_e
asn_strtoimax_lim
(
const
char
*
str
,
const
char
**
end
,
intmax_t
*
l
);
/* The asn_strtol is going to be DEPRECATED soon */
enum
asn_strtol_result_e
asn_strtol
(
const
char
*
str
,
const
char
*
end
,
long
*
l
);
/*
/*
* Convert the integer value into the corresponding enumeration map entry.
* Convert the integer value into the corresponding enumeration map entry.
...
...
skeletons/OBJECT_IDENTIFIER.c
View file @
72ec9097
...
@@ -668,20 +668,20 @@ OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length,
...
@@ -668,20 +668,20 @@ OBJECT_IDENTIFIER_parse_arcs(const char *oid_text, ssize_t oid_txt_length,
const char *endp = oid_end; \
const char *endp = oid_end; \
long value; \
long value; \
switch(asn_strtol_lim(oid_text, &endp, &value)) { \
switch(asn_strtol_lim(oid_text, &endp, &value)) { \
case ASN_STRTO
L
_EXTRA_DATA: \
case ASN_STRTO
X
_EXTRA_DATA: \
case ASN_STRTO
L
_OK: \
case ASN_STRTO
X
_OK: \
if(arcs_count < arcs_slots) \
if(arcs_count < arcs_slots) \
arcs[arcs_count] = value; \
arcs[arcs_count] = value; \
arcs_count++; \
arcs_count++; \
oid_text = endp - 1; \
oid_text = endp - 1; \
break; \
break; \
case ASN_STRTO
L
_ERROR_RANGE: \
case ASN_STRTO
X
_ERROR_RANGE: \
if(opt_oid_text_end) \
if(opt_oid_text_end) \
*opt_oid_text_end = oid_text; \
*opt_oid_text_end = oid_text; \
errno = ERANGE; \
errno = ERANGE; \
return -1; \
return -1; \
case ASN_STRTO
L
_ERROR_INVAL: \
case ASN_STRTO
X
_ERROR_INVAL: \
case ASN_STRTO
L
_EXPECT_MORE: \
case ASN_STRTO
X
_EXPECT_MORE: \
if(opt_oid_text_end) \
if(opt_oid_text_end) \
*opt_oid_text_end = oid_text; \
*opt_oid_text_end = oid_text; \
errno = EINVAL; \
errno = EINVAL; \
...
...
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