File: lua.hh

package info (click to toggle)
monotone 0.18-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 16,440 kB
  • ctags: 13,394
  • sloc: sh: 130,618; ansic: 70,657; cpp: 51,980; perl: 421; makefile: 359; python: 184; lisp: 132; sql: 83
file content (114 lines) | stat: -rw-r--r-- 4,513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef __LUA__
#define __LUA__

// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
// all rights reserved.
// licensed to the public under the terms of the GNU GPL (>= 2)
// see the file COPYING for details

// this file defines a typed C++ interface to the various hooks
// we expose to the user as lua functions or variables

#include <string>
#include <set>
#include <map>
#include "file_io.hh"
#include "vocab.hh"

struct patch_set;

struct lua_State;

class lua_hooks
{
  struct lua_State * st;
  template <typename RES>
  std::pair<bool,RES> call_hook(char const * name, int nargs, ...);

public:
  lua_hooks();
  ~lua_hooks();
#ifdef BUILD_UNIT_TESTS
  void add_test_hooks();
#endif
  void add_std_hooks();
  void working_copy_rcfilename(fs::path & file);
  void default_rcfilename(fs::path & file);
  void load_rcfile(fs::path const & file, bool required);

  // cert hooks
  bool hook_expand_selector(std::string const & sel, std::string & exp);
  bool hook_get_branch_key(cert_value const & branchname, rsa_keypair_id & k);
  bool lua_hooks::hook_get_priv_key(rsa_keypair_id const & k,
                                   base64< arc4<rsa_priv_key> > & priv_key );
  bool hook_get_passphrase(rsa_keypair_id const & k, std::string & phrase);
  bool hook_get_author(cert_value const & branchname, std::string & author);
  bool hook_edit_comment(std::string const & commentary,
                         std::string const & user_log_message,
                         std::string & result);  
  bool hook_persist_phrase_ok();
  bool hook_non_blocking_rng_ok();
  bool hook_get_revision_cert_trust(std::set<rsa_keypair_id> const & signers,
                                   hexenc<id> const & id,
                                   cert_name const & name,
                                   cert_value const & val);
  bool hook_get_manifest_cert_trust(std::set<rsa_keypair_id> const & signers,
                                    hexenc<id> const & id,
                                    cert_name const & name,
                                    cert_value const & val);
  bool hook_accept_testresult_change(std::map<rsa_keypair_id, bool> const & old_results,
                                     std::map<rsa_keypair_id, bool> const & new_results);

  // network hooks
  bool hook_get_netsync_read_permitted(std::string const & collection, 
                                       rsa_keypair_id const & identity);
  bool hook_get_netsync_anonymous_read_permitted(std::string const & collection);
  bool hook_get_netsync_write_permitted(std::string const & collection, 
                                        rsa_keypair_id const & identity);

  // local repo hooks
  bool hook_ignore_file(file_path const & p);
  bool hook_ignore_branch(std::string const & branch);
  bool hook_merge2(file_path const & left_path,
                   file_path const & right_path,
                   file_path const & merged_path,
                   data const & left, 
                   data const & right, 
                   data & result);
  bool hook_merge3(file_path const & anc_path,
                   file_path const & left_path,
                   file_path const & right_path,
                   file_path const & merged_path,
                   data const & ancestor, 
                   data const & left, 
                   data const & right, 
                   data & result);

  bool hook_resolve_file_conflict(file_path const & anc,
                                  file_path const & a,
                                  file_path const & b,
                                  file_path & res);

  bool hook_resolve_dir_conflict(file_path const & anc,
                                 file_path const & a,
                                 file_path const & b,
                                 file_path & res);

  // attribute hooks
  bool hook_apply_attribute(std::string const & attr, 
                            file_path const & filename, 
                            std::string const & value);

  // conversion hooks
  bool hook_get_system_linesep(std::string & linesep);
  bool hook_get_charset_conv(file_path const & p, 
                             std::string & db, std::string & ext);
  bool hook_get_linesep_conv(file_path const & p, 
                             std::string & db, std::string & ext);

  // notification hooks
  bool hook_note_commit(revision_id const & new_id,
                        std::map<cert_name, cert_value> const & certs);
};

#endif // __LUA_HH__