diff options
Diffstat (limited to 'security/nss/cmd/oidcalc')
-rw-r--r-- | security/nss/cmd/oidcalc/Makefile | 48 | ||||
-rw-r--r-- | security/nss/cmd/oidcalc/manifest.mn | 19 | ||||
-rw-r--r-- | security/nss/cmd/oidcalc/oidcalc.c | 86 | ||||
-rw-r--r-- | security/nss/cmd/oidcalc/oidcalc.gyp | 30 |
4 files changed, 183 insertions, 0 deletions
diff --git a/security/nss/cmd/oidcalc/Makefile b/security/nss/cmd/oidcalc/Makefile new file mode 100644 index 0000000000..d7c879aec2 --- /dev/null +++ b/security/nss/cmd/oidcalc/Makefile @@ -0,0 +1,48 @@ +#! gmake +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +####################################################################### +# (1) Include initial platform-independent assignments (MANDATORY). # +####################################################################### + +include manifest.mn + +####################################################################### +# (2) Include "global" configuration information. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/config.mk + +####################################################################### +# (3) Include "component" configuration information. (OPTIONAL) # +####################################################################### + +####################################################################### +# (4) Include "local" platform-dependent assignments (OPTIONAL). # +####################################################################### + +include ../platlibs.mk + + +####################################################################### +# (5) Execute "global" rules. (OPTIONAL) # +####################################################################### + +include $(CORE_DEPTH)/coreconf/rules.mk + +####################################################################### +# (6) Execute "component" rules. (OPTIONAL) # +####################################################################### + + + +####################################################################### +# (7) Execute "local" rules. (OPTIONAL). # +####################################################################### + + +include ../platrules.mk + diff --git a/security/nss/cmd/oidcalc/manifest.mn b/security/nss/cmd/oidcalc/manifest.mn new file mode 100644 index 0000000000..e7976c6616 --- /dev/null +++ b/security/nss/cmd/oidcalc/manifest.mn @@ -0,0 +1,19 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +CORE_DEPTH = ../.. + +# MODULE public and private header directories are implicitly REQUIRED. +MODULE = nss + +# This next line is used by .mk files +# and gets translated into $LINCS in manifest.mnw +REQUIRES = seccmd dbm + +DEFINES = -DNSPR20 + +CSRCS = oidcalc.c + +PROGRAM = oidcalc diff --git a/security/nss/cmd/oidcalc/oidcalc.c b/security/nss/cmd/oidcalc/oidcalc.c new file mode 100644 index 0000000000..46ef56c411 --- /dev/null +++ b/security/nss/cmd/oidcalc/oidcalc.c @@ -0,0 +1,86 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int +main(int argc, char **argv) +{ + char *curstr; + char *nextstr; + unsigned int firstval; + unsigned int secondval; + unsigned int val; + unsigned char buf[5]; + int count; + + if (argc != 2) { + fprintf(stderr, "wrong number of args\n"); + exit(-1); + } + + curstr = argv[1]; + + nextstr = strchr(curstr, '.'); + + if (nextstr == NULL) { + fprintf(stderr, "only one component\n"); + exit(-1); + } + + *nextstr = '\0'; + firstval = atoi(curstr); + + curstr = nextstr + 1; + + nextstr = strchr(curstr, '.'); + + if (nextstr) { + *nextstr = '\0'; + } + + secondval = atoi(curstr); + + if (firstval > 2) { + fprintf(stderr, "first component out of range\n"); + exit(-1); + } + + if (secondval > 39) { + fprintf(stderr, "second component out of range\n"); + exit(-1); + } + + printf("0x%x, ", (firstval * 40) + secondval); + while (nextstr) { + curstr = nextstr + 1; + + nextstr = strchr(curstr, '.'); + + if (nextstr) { + *nextstr = '\0'; + } + + memset(buf, 0, sizeof(buf)); + val = atoi(curstr); + count = 0; + while (val) { + buf[count] = (val & 0x7f); + val = val >> 7; + count++; + } + + while (count--) { + if (count) { + printf("0x%x, ", buf[count] | 0x80); + } else { + printf("0x%x, ", buf[count]); + } + } + } + printf("\n"); + return 0; +} diff --git a/security/nss/cmd/oidcalc/oidcalc.gyp b/security/nss/cmd/oidcalc/oidcalc.gyp new file mode 100644 index 0000000000..b02ab87216 --- /dev/null +++ b/security/nss/cmd/oidcalc/oidcalc.gyp @@ -0,0 +1,30 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +{ + 'includes': [ + '../../coreconf/config.gypi', + '../../cmd/platlibs.gypi' + ], + 'targets': [ + { + 'target_name': 'oidcalc', + 'type': 'executable', + 'sources': [ + 'oidcalc.c' + ], + 'dependencies': [ + '<(DEPTH)/exports.gyp:dbm_exports', + '<(DEPTH)/exports.gyp:nss_exports' + ] + } + ], + 'target_defaults': { + 'defines': [ + 'NSPR20' + ] + }, + 'variables': { + 'module': 'nss' + } +}
\ No newline at end of file |