|
Packit |
728676 |
/*-
|
|
Packit |
728676 |
* Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
|
Packit |
728676 |
* Redistribution and modifications are permitted subject to BSD license.
|
|
Packit |
728676 |
*/
|
|
Packit |
728676 |
#ifndef _INTEGER_H_
|
|
Packit |
728676 |
#define _INTEGER_H_
|
|
Packit |
728676 |
|
|
Packit |
728676 |
#include <asn_application.h>
|
|
Packit |
728676 |
#include <asn_codecs_prim.h>
|
|
Packit |
728676 |
|
|
Packit |
728676 |
#ifdef __cplusplus
|
|
Packit |
728676 |
extern "C" {
|
|
Packit |
728676 |
#endif
|
|
Packit |
728676 |
|
|
Packit |
728676 |
typedef ASN__PRIMITIVE_TYPE_t INTEGER_t;
|
|
Packit |
728676 |
|
|
Packit |
728676 |
extern asn_TYPE_descriptor_t asn_DEF_INTEGER;
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/* Map with <tag> to integer value association */
|
|
Packit |
728676 |
typedef struct asn_INTEGER_enum_map_s {
|
|
Packit |
728676 |
long nat_value; /* associated native integer value */
|
|
Packit |
728676 |
size_t enum_len; /* strlen("tag") */
|
|
Packit |
728676 |
const char *enum_name; /* "tag" */
|
|
Packit |
728676 |
} asn_INTEGER_enum_map_t;
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/* This type describes an enumeration for INTEGER and ENUMERATED types */
|
|
Packit |
728676 |
typedef struct asn_INTEGER_specifics_s {
|
|
Packit |
728676 |
asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
|
|
Packit |
728676 |
unsigned int *enum2value; /* "tag" => N; sorted by tag */
|
|
Packit |
728676 |
int map_count; /* Elements in either map */
|
|
Packit |
728676 |
int extension; /* This map is extensible */
|
|
Packit |
728676 |
int strict_enumeration; /* Enumeration set is fixed */
|
|
Packit |
728676 |
int field_width; /* Size of native integer */
|
|
Packit |
728676 |
int field_unsigned; /* Signed=0, unsigned=1 */
|
|
Packit |
728676 |
} asn_INTEGER_specifics_t;
|
|
Packit |
728676 |
|
|
Packit |
728676 |
asn_struct_print_f INTEGER_print;
|
|
Packit |
728676 |
ber_type_decoder_f INTEGER_decode_ber;
|
|
Packit |
728676 |
der_type_encoder_f INTEGER_encode_der;
|
|
Packit |
728676 |
xer_type_decoder_f INTEGER_decode_xer;
|
|
Packit |
728676 |
xer_type_encoder_f INTEGER_encode_xer;
|
|
Packit |
728676 |
per_type_decoder_f INTEGER_decode_uper;
|
|
Packit |
728676 |
per_type_encoder_f INTEGER_encode_uper;
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/***********************************
|
|
Packit |
728676 |
* Some handy conversion routines. *
|
|
Packit |
728676 |
***********************************/
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/*
|
|
Packit |
728676 |
* Returns 0 if it was possible to convert, -1 otherwise.
|
|
Packit |
728676 |
* -1/EINVAL: Mandatory argument missing
|
|
Packit |
728676 |
* -1/ERANGE: Value encoded is out of range for long representation
|
|
Packit |
728676 |
* -1/ENOMEM: Memory allocation failed (in asn_long2INTEGER()).
|
|
Packit |
728676 |
*/
|
|
Packit |
728676 |
int asn_INTEGER2long(const INTEGER_t *i, long *l);
|
|
Packit |
728676 |
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
|
|
Packit |
728676 |
int asn_long2INTEGER(INTEGER_t *i, long l);
|
|
Packit |
728676 |
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/* A a reified version of strtol(3) with nicer error reporting. */
|
|
Packit |
728676 |
enum asn_strtol_result_e {
|
|
Packit |
728676 |
ASN_STRTOL_ERROR_RANGE = -3, /* Input outside of numeric range for long type */
|
|
Packit |
728676 |
ASN_STRTOL_ERROR_INVAL = -2, /* Invalid data encountered (e.g., "+-") */
|
|
Packit |
728676 |
ASN_STRTOL_EXPECT_MORE = -1, /* More data expected (e.g. "+") */
|
|
Packit |
728676 |
ASN_STRTOL_OK = 0, /* Conversion succeded, number ends at (*end) */
|
|
Packit |
728676 |
ASN_STRTOL_EXTRA_DATA = 1, /* Conversion succeded, but the string has extra stuff */
|
|
Packit |
728676 |
};
|
|
Packit |
728676 |
enum asn_strtol_result_e asn_strtol_lim(const char *str, const char **end, long *l);
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/* The asn_strtol is going to be DEPRECATED soon */
|
|
Packit |
728676 |
enum asn_strtol_result_e asn_strtol(const char *str, const char *end, long *l);
|
|
Packit |
728676 |
|
|
Packit |
728676 |
/*
|
|
Packit |
728676 |
* Convert the integer value into the corresponding enumeration map entry.
|
|
Packit |
728676 |
*/
|
|
Packit |
728676 |
const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(asn_INTEGER_specifics_t *specs, long value);
|
|
Packit |
728676 |
|
|
Packit |
728676 |
#ifdef __cplusplus
|
|
Packit |
728676 |
}
|
|
Packit |
728676 |
#endif
|
|
Packit |
728676 |
|
|
Packit |
728676 |
#endif /* _INTEGER_H_ */
|