monotone

monotone Mtn Source Tree

Root/botan/oids.cpp

1/*************************************************
2* OID Registry Source File *
3* (C) 1999-2006 The Botan Project *
4*************************************************/
5
6#include <botan/oids.h>
7#include <botan/config.h>
8
9namespace Botan {
10
11namespace OIDS {
12
13/*************************************************
14* Register an OID to string mapping *
15*************************************************/
16void add_oid(const OID& oid, const std::string& name)
17 {
18 const std::string oid_str = oid.as_string();
19
20 if(!global_config().is_set("oid2str", oid_str))
21 global_config().set("oid2str", oid_str, name);
22 if(!global_config().is_set("str2oid", name))
23 global_config().set("str2oid", name, oid_str);
24 }
25
26/*************************************************
27* Do an OID to string lookup *
28*************************************************/
29std::string lookup(const OID& oid)
30 {
31 std::string name = global_config().get("oid2str", oid.as_string());
32 if(name == "")
33 return oid.as_string();
34 return name;
35 }
36
37/*************************************************
38* Do a string to OID lookup *
39*************************************************/
40OID lookup(const std::string& name)
41 {
42 std::string value = global_config().get("str2oid", name);
43 if(value == "")
44 return OID(name);
45 return OID(value);
46 }
47
48/*************************************************
49* Check to see if an OID exists in the table *
50*************************************************/
51bool have_oid(const std::string& name)
52 {
53 return global_config().is_set("str2oid", name);
54 }
55
56/*************************************************
57* Check to see if an OID exists in the table *
58*************************************************/
59bool name_of(const OID& oid, const std::string& name)
60 {
61 return (oid == lookup(name));
62 }
63
64}
65
66}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status