fish.c: don't perform arithmetic on void* pointers
[libguestfs.git] / HACKING
1 PLEASE LOOK AT THE TOP OF EACH FILE BEFORE EDITING TO SEE WHETHER IT
2 IS AUTOMATICALLY GENERATED OR NOT.
3
4 Adding a new action
5 ----------------------------------------------------------------------
6
7 All action functions are generated automatically, so there are only
8 two files you need to edit:
9
10 (1) src/generator.ml: Add your new action, parameters, description,
11 etc. to the big list called 'functions' at the top of this file.
12
13 (2) Edit/create a C file in daemon/ subdirectory which implements your
14 'do_action' function.  Take a look at one of the numerous examples
15 there.
16
17 Formatting
18 ----------------------------------------------------------------------
19
20 Try to use GNU / Emacs default formatting, following the convention
21 used elsewhere in the source.
22
23 Please make sure that the code compiles without warnings.
24
25 Please test any changes.
26
27 Useful targets:
28   make syntax-check    Checks the syntax of the C code.
29   make check           Runs the test suite.
30
31 Enable warnings, and fix any you find:
32   ./configure --enable-gcc-warnings
33
34 Code indentation
35 ----------------------------------------------------------------------
36 Our C source code generally adheres to some basic code-formatting
37 conventions.  The existing code base is not totally consistent on this
38 front, but we do prefer that contributed code be formatted similarly.
39 In short, use spaces-not-TABs for indentation, use 2 spaces for each
40 indentation level, and other than that, follow the K&R style.
41
42 If you use Emacs, add the following to one of one of your start-up files
43 (e.g., ~/.emacs), to help ensure that you get indentation right:
44
45   ;;; In libguestfs, indent with spaces everywhere (not TABs).
46   ;;; Exceptions: Makefile and ChangeLog modes.
47   (add-hook 'find-file-hook
48       '(lambda () (if (and buffer-file-name
49                            (string-match "/libguestfs\\>" (buffer-file-name))
50                            (not (string-equal mode-name "Change Log"))
51                            (not (string-equal mode-name "Makefile")))
52                       (setq indent-tabs-mode nil))))
53
54   ;;; When editing C sources in libguestfs, use this style.
55   (defun libguestfs-c-mode ()
56     "C mode with adjusted defaults for use with libguestfs."
57     (interactive)
58     (c-set-style "K&R")
59     (setq c-indent-level 2)
60     (setq c-basic-offset 2))
61   (add-hook 'c-mode-hook
62             '(lambda () (if (string-match "/libguestfs\\>" (buffer-file-name))
63                             (libguestfs-c-mode))))
64
65 Directories
66 ----------------------------------------------------------------------
67
68 appliance/
69         The qemu appliance, build scripts and so on.
70
71 cat/
72         The virt-cat tool.
73
74 capitests/
75         Automated tests of the C API.
76
77 contrib/
78         Outside contributions, experimental parts.
79
80 daemon/
81         The daemon that runs inside the guest and carries out actions.
82
83 df/
84         The virt-df tool.
85
86 examples/
87         The examples.
88
89 fish/
90         Guestfish (the command-line program / shell)
91
92 haskell/
93         Haskell bindings.
94
95 images/
96         Some guest images to test against.  These are gzipped to save
97         space.  You have to unzip them before use.
98
99         Also contains some files used by the test suite.
100
101 inspector/
102         Virtual machine image inspector (virt-inspector).
103
104 java/
105         Java bindings.
106
107 m4/
108         M4 macros used by autoconf.
109
110 ocaml/
111         OCaml bindings.
112
113 po/
114         Translations.
115
116 perl/
117         Perl bindings.
118
119 python/
120         Python bindings.
121
122 regressions/
123         Regression tests.
124
125 ruby/
126         Ruby bindings.
127
128 src/
129         Source code to the C library.
130         Also contains the crucial generator program.
131
132 test-tool/
133         Interactive qemu/kernel test tool.
134
135 Debugging
136 ----------------------------------------------------------------------
137
138 It's a good idea to use guestfish to try out new commands.
139
140 Debugging the daemon is a problem because it runs inside a minimal
141 qemu environment.  However you can print messages from the daemon, and
142 they will show up if you use 'guestfish -v'.
143
144 Patches
145 ----------------------------------------------------------------------
146
147 Submit patches to the mailing list:
148 http://www.redhat.com/mailman/listinfo/libguestfs
149 and CC to rjones@redhat.com
150
151 I18N
152 ----------------------------------------------------------------------
153
154 We support i18n (gettext anyhow) in the library.
155
156 However many messages come from the daemon, and we don't translate
157 those at the moment.  One reason is that the appliance generally has
158 all locale files removed from it, because they take up a lot of space.
159 So we'd have to readd some of those, as well as copying our PO files
160 into the appliance.
161
162 Debugging messages are never translated, since they are intended for
163 the programmers.
164
165 Extended printf
166 ----------------------------------------------------------------------
167
168 In the daemon code we have created custom printf formatters %Q and %R,
169 which are used to do shell quoting.
170
171 %Q => Simple shell quoted string.  Any spaces or other shell characters
172       are escaped for you.
173
174 %R => Same as %Q except the string is treated as a path which is prefixed
175       by the sysroot.
176
177 eg.
178
179 asprintf (&cmd, "cat %R", path);
180 ==> "cat /sysroot/some\ path\ with\ spaces"
181
182 Note: Do NOT use these when you are passing parameters to the
183 command{,r,v,rv}() functions.  These parameters do NOT need to be
184 quoted because they are not passed via the shell (instead, straight to
185 exec).  You probably want to use the sysroot_path() function however.