1 /*
2 * Parser Functions
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7 
8 #ifndef BOTAN_PARSER_H__
9 #define BOTAN_PARSER_H__
10 
11 #include <botan/types.h>
12 #include <string>
13 #include <vector>
14 
15 namespace Botan {
16 
17 /**
18 * Parse a SCAN-style algorithm name
19 * @param scan_name the name
20 * @return the name components
21 */
22 BOTAN_DLL std::vector<std::string>
23 parse_algorithm_name(const std::string& scan_name);
24 
25 /**
26 * Split a string
27 * @param str the input string
28 * @param delim the delimitor
29 * @return string split by delim
30 */
31 BOTAN_DLL std::vector<std::string> split_on(
32    const std::string& str, char delim);
33 
34 /**
35 * Parse an ASN.1 OID
36 * @param oid the OID in string form
37 * @return OID components
38 */
39 BOTAN_DLL std::vector<u32bit> parse_asn1_oid(const std::string& oid);
40 
41 /**
42 * Compare two names using the X.509 comparison algorithm
43 * @param name1 the first name
44 * @param name2 the second name
45 * @return true if name1 is the same as name2 by the X.509 comparison rules
46 */
47 BOTAN_DLL bool x500_name_cmp(const std::string& name1,
48                              const std::string& name2);
49 
50 /**
51 * Convert a number to a string
52 * @param n the integer to convert to a string
53 * @param min_len the min length of the output string
54 * @return n convert to a string
55 */
56 BOTAN_DLL std::string to_string(u64bit n, size_t min_len = 0);
57 
58 /**
59 * Convert a string to a number
60 * @param str the string to convert
61 * @return number value of the string
62 */
63 BOTAN_DLL u32bit to_u32bit(const std::string& str);
64 
65 /**
66 * Convert a time specification to a number
67 * @param timespec the time specification
68 * @return number of seconds represented by timespec
69 */
70 BOTAN_DLL u32bit timespec_to_u32bit(const std::string& timespec);
71 
72 /**
73 * Convert a string representation of an IPv4 address to a number
74 * @param ip_str the string representation
75 * @return integer IPv4 address
76 */
77 BOTAN_DLL u32bit string_to_ipv4(const std::string& ip_str);
78 
79 /**
80 * Convert an IPv4 address to a string
81 * @param ip_addr the IPv4 address to convert
82 * @return string representation of the IPv4 address
83 */
84 BOTAN_DLL std::string ipv4_to_string(u32bit ip_addr);
85 
86 }
87 
88 #endif
89