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
32{
33 cert();
34
35 // This is to make revision<cert> and manifest<cert> work.
36 explicit cert(std::string const & s);
37
38 cert(revision_id const & ident,
39 cert_name const & name,
40 cert_value const & value,
41 rsa_keypair_id const & key);
42 cert(revision_id const & ident,
43 cert_name const & name,
44 cert_value const & value,
45 rsa_keypair_id const & key,
46 rsa_sha1_signature const & sig);
47 revision_id ident;
48 cert_name name;
49 cert_value value;
50 rsa_keypair_id key;
51 rsa_sha1_signature sig;
52 bool operator<(cert const & other) const;
53 bool operator==(cert const & other) const;
54};
55
56EXTERN template class revision<cert>;
57EXTERN template class manifest<cert>;
58
59
60// These 3 are for netio support.
61void read_cert(std::string const & in, cert & t);
62void write_cert(cert const & t, std::string & out);
63void cert_hash_code(cert const & t, id & out);
64
65typedef enum {cert_ok, cert_bad, cert_unknown} cert_status;
66
67void cert_signable_text(cert const & t,std::string & out);
68cert_status check_cert(database & db, cert const & t);
69
70bool put_simple_revision_cert(database & db,
71 key_store & keys,
72 revision_id const & id,
73 cert_name const & nm,
74 cert_value const & val);
75
76void erase_bogus_certs(database & db, std::vector< revision<cert> > & certs);
77void erase_bogus_certs(database & db, std::vector< manifest<cert> > & certs);
78
79// Special certs -- system won't work without them.
80
81#define branch_cert_name cert_name("branch")
82
83void
84cert_revision_in_branch(database & db, key_store & keys,
85 revision_id const & rev,
86 branch_name const & branchname);
87
88
89// We also define some common cert types, to help establish useful
90// conventions. you should use these unless you have a compelling
91// reason not to.
92
93void
94guess_branch(options & opts, project_t & project, revision_id const & rev,
95 branch_name & branchname);
96void
97guess_branch(options & opts, project_t & project, revision_id const & rev);
98
99#define date_cert_name cert_name("date")
100#define author_cert_name cert_name("author")
101#define tag_cert_name cert_name("tag")
102#define changelog_cert_name cert_name("changelog")
103#define comment_cert_name cert_name("comment")
104#define testresult_cert_name cert_name("testresult")
105#define suspend_cert_name cert_name("suspend")
106
107void
108cert_revision_suspended_in_branch(database & db, key_store & keys,
109 revision_id const & rev,
110 branch_name const & branchname);
111
112void
113cert_revision_date_time(database & db, key_store & keys,
114 revision_id const & rev,
115 date_t const & t);
116
117void
118cert_revision_author(database & db, key_store & keys,
119 revision_id const & m,
120 std::string const & author);
121
122void
123cert_revision_tag(database & db, key_store & keys,
124 revision_id const & rev,
125 std::string const & tagname);
126
127void
128cert_revision_changelog(database & db, key_store & keys,
129 revision_id const & rev,
130 utf8 const & changelog);
131
132void
133cert_revision_comment(database & db, key_store & keys,
134 revision_id const & m,
135 utf8 const & comment);
136
137void
138cert_revision_testresult(database & db, key_store & keys,
139 revision_id const & m,
140 std::string const & results);
141
142
143// Local Variables:
144// mode: C++
145// fill-column: 76
146// c-file-style: "gnu"
147// indent-tabs-mode: nil
148// End:
149// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
150
151#endif // __CERT_HH__

Archive Download this file

Branches

Tags

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