monotone

monotone Mtn Source Tree

Root/cert.hh

1#ifndef __CERT_HH__
2#define __CERT_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include <map>
14#include <set>
15#include "vector.hh"
16
17#include "vocab.hh"
18#include "dates.hh"
19
20// Certs associate an opaque name/value pair with a revision ID, and
21// are accompanied by an RSA public-key signature attesting to the
22// association. Users can write as much extra meta-data as they like
23// about revisions, using certs, without needing anyone's special
24// permission.
25
26class key_store;
27class database;
28class project_t;
29struct options;
30
31struct cert : public origin_aware
32{
33 cert();
34
35 // This is to make revision<cert> and manifest<cert> work.
36 explicit cert(std::string const & s);
37 cert(std::string const & s, made_from_t m);
38
39 cert(revision_id const & ident,
40 cert_name const & name,
41 cert_value const & value,
42 rsa_keypair_id const & key);
43 cert(revision_id const & ident,
44 cert_name const & name,
45 cert_value const & value,
46 rsa_keypair_id const & key,
47 rsa_sha1_signature const & sig);
48 revision_id ident;
49 cert_name name;
50 cert_value value;
51 rsa_keypair_id key;
52 rsa_sha1_signature sig;
53 bool operator<(cert const & other) const;
54 bool operator==(cert const & other) const;
55};
56
57EXTERN template class revision<cert>;
58EXTERN template class manifest<cert>;
59
60
61// These 3 are for netio support.
62void read_cert(std::string const & in, cert & t);
63void write_cert(cert const & t, std::string & out);
64void cert_hash_code(cert const & t, id & out);
65
66typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
67
68void cert_signable_text(cert const & t,std::string & out);
69cert_status check_cert(database & db, cert const & t);
70
71bool put_simple_revision_cert(database & db,
72 key_store & keys,
73 revision_id const & id,
74 cert_name const & nm,
75 cert_value const & val);
76
77void erase_bogus_certs(database & db, std::vector< revision<cert> > & certs);
78void erase_bogus_certs(database & db, std::vector< manifest<cert> > & certs);
79
80// Special certs -- system won't work without them.
81
82#define branch_cert_name cert_name("branch")
83
84void
85cert_revision_in_branch(database & db, key_store & keys,
86 revision_id const & rev,
87 branch_name const & branchname);
88
89
90// We also define some common cert types, to help establish useful
91// conventions. you should use these unless you have a compelling
92// reason not to.
93
94void
95guess_branch(options & opts, project_t & project, revision_id const & rev,
96 branch_name & branchname);
97void
98guess_branch(options & opts, project_t & project, revision_id const & rev);
99
100#define date_cert_name cert_name("date")
101#define author_cert_name cert_name("author")
102#define tag_cert_name cert_name("tag")
103#define changelog_cert_name cert_name("changelog")
104#define comment_cert_name cert_name("comment")
105#define testresult_cert_name cert_name("testresult")
106#define suspend_cert_name cert_name("suspend")
107
108void
109cert_revision_suspended_in_branch(database & db, key_store & keys,
110 revision_id const & rev,
111 branch_name const & branchname);
112
113void
114cert_revision_date_time(database & db, key_store & keys,
115 revision_id const & rev,
116 date_t const & t);
117
118void
119cert_revision_author(database & db, key_store & keys,
120 revision_id const & m,
121 std::string const & author);
122
123void
124cert_revision_tag(database & db, key_store & keys,
125 revision_id const & rev,
126 std::string const & tagname);
127
128void
129cert_revision_changelog(database & db, key_store & keys,
130 revision_id const & rev,
131 utf8 const & changelog);
132
133void
134cert_revision_comment(database & db, key_store & keys,
135 revision_id const & m,
136 utf8 const & comment);
137
138void
139cert_revision_testresult(database & db, key_store & keys,
140 revision_id const & m,
141 std::string const & results);
142
143
144// Local Variables:
145// mode: C++
146// fill-column: 76
147// c-file-style: "gnu"
148// indent-tabs-mode: nil
149// End:
150// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
151
152#endif // __CERT_HH__

Archive Download this file

Branches

Tags

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