Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / PrintableString.c
diff --git a/asn1c_defs/all-defs/PrintableString.c b/asn1c_defs/all-defs/PrintableString.c
new file mode 100755 (executable)
index 0000000..bbeb145
--- /dev/null
@@ -0,0 +1,130 @@
+/*-\r
+ * Copyright (c) 2003, 2004, 2006 Lev Walkin <vlm@lionet.info>.\r
+ * All rights reserved.\r
+ * Redistribution and modifications are permitted subject to BSD license.\r
+ */\r
+#include <asn_internal.h>\r
+#include <PrintableString.h>\r
+\r
+/*\r
+ * ASN.1:1984 (X.409)\r
+ */\r
+static const int _PrintableString_alphabet[256] = {\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /*                  */\r
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /*                  */\r
+ 1, 0, 0, 0, 0, 0, 0, 2, 3, 4, 0, 5, 6, 7, 8, 9,       /* .      '() +,-./ */\r
+10,11,12,13,14,15,16,17,18,19,20, 0, 0,21, 0,22,       /* 0123456789:  = ? */\r
+ 0,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,       /*  ABCDEFGHIJKLMNO */\r
+38,39,40,41,42,43,44,45,46,47,48, 0, 0, 0, 0, 0,       /* PQRSTUVWXYZ      */\r
+ 0,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,       /*  abcdefghijklmno */\r
+64,65,66,67,68,69,70,71,72,73,74, 0, 0, 0, 0, 0,       /* pqrstuvwxyz      */\r
+};\r
+static const int _PrintableString_code2value[74] = {\r
+32,39,40,41,43,44,45,46,47,48,49,50,51,52,53,54,\r
+55,56,57,58,61,63,65,66,67,68,69,70,71,72,73,74,\r
+75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,\r
+97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,\r
+113,114,115,116,117,118,119,120,121,122};\r
+\r
+/*\r
+ * PrintableString basic type description.\r
+ */\r
+static const ber_tlv_tag_t asn_DEF_PrintableString_tags[] = {\r
+       (ASN_TAG_CLASS_UNIVERSAL | (19 << 2)),  /* [UNIVERSAL 19] IMPLICIT ...*/\r
+       (ASN_TAG_CLASS_UNIVERSAL | (4 << 2))    /* ... OCTET STRING */\r
+};\r
+static int asn_DEF_PrintableString_v2c(unsigned int value) {\r
+       return _PrintableString_alphabet[value > 255 ? 0 : value] - 1;\r
+}\r
+static int asn_DEF_PrintableString_c2v(unsigned int code) {\r
+       if(code < 74)\r
+               return _PrintableString_code2value[code];\r
+       return -1;\r
+}\r
+static asn_per_constraints_t asn_DEF_PrintableString_per_constraints = {\r
+       { APC_CONSTRAINED, 4, 4, 0x20, 0x39 },  /* Value */\r
+       { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */\r
+       asn_DEF_PrintableString_v2c,\r
+       asn_DEF_PrintableString_c2v\r
+};\r
+asn_TYPE_operation_t asn_OP_PrintableString = {\r
+       OCTET_STRING_free,\r
+       OCTET_STRING_print_utf8,        /* ASCII subset */\r
+       OCTET_STRING_compare,\r
+       OCTET_STRING_decode_ber,      /* Implemented in terms of OCTET STRING */\r
+       OCTET_STRING_encode_der,\r
+       OCTET_STRING_decode_xer_utf8,\r
+       OCTET_STRING_encode_xer_utf8,\r
+#ifdef ASN_DISABLE_OER_SUPPORT\r
+       0,\r
+       0,\r
+#else\r
+       OCTET_STRING_decode_oer,\r
+       OCTET_STRING_encode_oer,\r
+#endif /* ASN_DISABLE_OER_SUPPORT */\r
+#ifdef ASN_DISABLE_PER_SUPPORT\r
+       0,\r
+       0,\r
+       0,\r
+       0,\r
+#else\r
+       OCTET_STRING_decode_uper,\r
+       OCTET_STRING_encode_uper,\r
+       OCTET_STRING_decode_aper,\r
+       OCTET_STRING_encode_aper,\r
+#endif /* ASN_DISABLE_PER_SUPPORT */\r
+       OCTET_STRING_random_fill,\r
+       0       /* Use generic outmost tag fetcher */\r
+};\r
+asn_TYPE_descriptor_t asn_DEF_PrintableString = {\r
+       "PrintableString",\r
+       "PrintableString",\r
+       &asn_OP_PrintableString,\r
+       asn_DEF_PrintableString_tags,\r
+       sizeof(asn_DEF_PrintableString_tags)\r
+         / sizeof(asn_DEF_PrintableString_tags[0]) - 1,\r
+       asn_DEF_PrintableString_tags,\r
+       sizeof(asn_DEF_PrintableString_tags)\r
+         / sizeof(asn_DEF_PrintableString_tags[0]),\r
+       { 0, &asn_DEF_PrintableString_per_constraints, PrintableString_constraint },\r
+       0, 0,   /* No members */\r
+       0       /* No specifics */\r
+};\r
+\r
+\r
+int\r
+PrintableString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,\r
+                           asn_app_constraint_failed_f *ctfailcb,\r
+                           void *app_key) {\r
+    const PrintableString_t *st = (const PrintableString_t *)sptr;\r
+\r
+       if(st && st->buf) {\r
+               uint8_t *buf = st->buf;\r
+               uint8_t *end = buf + st->size;\r
+\r
+               /*\r
+                * Check the alphabet of the PrintableString.\r
+                * ASN.1:1984 (X.409)\r
+                */\r
+               for(; buf < end; buf++) {\r
+                       if(!_PrintableString_alphabet[*buf]) {\r
+                               ASN__CTFAIL(app_key, td, sptr,\r
+                                       "%s: value byte %ld (%d) "\r
+                                       "not in PrintableString alphabet "\r
+                                       "(%s:%d)",\r
+                                       td->name,\r
+                                       (long)((buf - st->buf) + 1),\r
+                                       *buf,\r
+                                       __FILE__, __LINE__);\r
+                               return -1;\r
+                       }\r
+               }\r
+       } else {\r
+               ASN__CTFAIL(app_key, td, sptr,\r
+                       "%s: value not given (%s:%d)",\r
+                       td->name, __FILE__, __LINE__);\r
+               return -1;\r
+       }\r
+\r
+       return 0;\r
+}\r