]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/fr/developers/generaldevel.tex
7c153da2b91a1b3504288f7d949415cec67cb189
[bacula/docs] / docs / manuals / fr / developers / generaldevel.tex
1 %%
2 %%
3
4 \chapter{Bacula Developer Notes}
5 \label{_ChapterStart10}
6 \index{Bacula Developer Notes}
7 \index{Notes!Bacula Developer}
8 \addcontentsline{toc}{section}{Bacula Developer Notes}
9
10 \section{General}
11 \index{General}
12 \addcontentsline{toc}{subsection}{General}
13
14 This document is intended mostly for developers and describes the the general
15 framework of making Bacula source changes. 
16
17 \subsection{Contributions}
18 \index{Contributions}
19 \addcontentsline{toc}{subsubsection}{Contributions}
20
21 Contributions from programmers are broken into two groups. The first are
22 contributions that are aids and not essential to Bacula. In general, these
23 will be scripts or will go into and examples or contributions directory. 
24 For these kinds of non-essential contributions there is no obligation to do
25 a copyright assignment as described below. However, a copyright assignment
26 would still be appreciated.
27
28 The second class of contributions are those which will be integrated with
29 Bacula and become an essential part. Within this class of contributions, there
30 are two hurdles to surmount. One is getting your patch accepted, and two is
31 dealing with copyright issues. The following text describes some of the
32 requirements for such code. 
33
34 \subsection{Patches}
35 \index{Patches}
36 \addcontentsline{toc}{subsubsection}{Patches}
37
38 Subject to the copyright assignment described below, your patches should be
39 sent in {\bf diff -u} format relative to the current contents of the Source
40 Forge SVN, which is the easiest to understand and integrate.
41 Please be sure to use the Bacula indenting standard (see below).
42 If you have checked out the source with SVN, you can get a diff using:
43
44 \begin{verbatim}
45 svn update 
46 svn diff > change.patch
47 \end{verbatim}
48      
49 If you plan on doing significant development work over a period of time,
50 after having your first patch reviewed and approved, you will be eligible
51 for having developer SVN access so that you can commit your changes
52 directly to the SVN repository.  To do so, you will need a userid on Source
53 Forge.
54
55 \subsection{Copyrights}
56 \index{Copyrights}
57 \addcontentsline{toc}{subsubsection}{Copyrights}
58
59 To avoid future problems concerning changing licensing or
60 copyrights, all code contributions more than a hand full of lines
61 must be in the Public Domain or have the copyright transferred to
62 the Free Software Foundation Europe e.V. with a Fiduciary License
63 Agreement (FLA) as in the current code.  Note, prior to
64 November 2004, the code was copyrighted by Kern Sibbald and John
65 Walker.  After November 2004, the code was copyrighted by Kern
66 Sibbald, then on the 15th of November 2006, the copyright was
67 transferred to the Free Software Foundation Europe e.V.
68
69 Your name should be clearly indicated as the author of the code, and you
70 must be extremely careful not to violate any copyrights or use other
71 people's code without acknowledging it.  The purpose of this requirement is
72 to avoid future copyright, patent, or intellectual property problems.  
73 Please read the LICENSE agreement in the main source code
74 directory.  When you sign the Fiduciary License Agreement (FLA)
75 and send it in, you are argeeing to the terms of that LICENSE
76 file.
77
78 To understand the possible source of future problems, please
79 examine the difficulties Mozilla is (was?) having finding
80 previous contributors at \elink{
81 http://www.mozilla.org/MPL/missing.html}
82 {http://www.mozilla.org/MPL/missing.html}. The other important issue is to
83 avoid copyright, patent, or intellectual property violations as are currently
84 (May 2003) being claimed by SCO against IBM. 
85
86 Although the copyright will be held by the Free Software
87 Foundation Europe e.V., each developer is expected to indicate
88 that he wrote and/or modified a particular module (or file) and
89 any other sources.  The copyright assignment may seem a bit
90 unusual, but in reality, it is not.  Most large projects require
91 this.
92
93 If you have any doubts about this, please don't hesitate to ask.  The
94 objective is to assure the long term servival of the Bacula project. 
95
96 Items not needing a copyright assignment are: most small changes,
97 enhancements, or bug fixes of 5-10 lines of code, which amount to    
98 less than 20% of any particular file.
99
100 \subsection{Copyright Assignment -- Fiduciary License Agreement}
101 \index{Copyright Assignment}
102 \index{Assignment!Copyright}
103 \addcontentsline{toc}{subsubsection}{Copyright Assignment -- Fiduciary License Agreement}
104
105 Since this is not a commercial enterprise, and we prefer to believe in
106 everyone's good faith, previously developers could assign the copyright by
107 explicitly acknowledging that they do so in their first submission.  This
108 was sufficient if the developer is independent, or an employee of a
109 not-for-profit organization or a university.  However, in an effort to
110 ensure that the Bacula code is really clean, beginning in August 2006, all
111 previous and future developers with SVN access will be asked to submit a
112 copyright assignment (or Fiduciary License Agreement -- FLA),
113 which means you agree to the LICENSE in the main source
114 directory. It also means that you receive back the right to use
115 the code that you have submitted.
116
117 Any developer who wants to contribute and is employed by a company should
118 either list the employer as the owner of the code, or get
119 explicit permission from him to sign the copyright assignment.
120 This is because in many
121 countries, all work that an employee does whether on company time or in the
122 employee's free time is considered to be Intellectual Property of the
123 company.  Obtaining official approval or an FLA from the company will avoid
124 misunderstandings between the employee, the company, and the Bacula
125 project.  A good number of companies have already followed this procedure.
126
127 The Fiduciary License Agreement is posted on the Bacula web site at:
128 \elink{http://www.bacula.org/fr/FLA-bacula.en.pdf}{http://www.bacula.org/fr/FLA-bacula.en.pdf}
129
130 The instructions for filling out this agreement are also at:
131 \elink{http://www.bacula.org/?page=fsfe}{http://www.bacula.org/?page=fsfe}
132
133 It should be filled out, then sent to:
134
135 \begin{verbatim}
136      Free Software Foundation Europe
137      Freedom Task Force
138      Sumatrastrasse 25
139      8006 Zürich
140      Switzerland
141 \end{verbatim}
142
143 Please note that the above address is different from the officially
144 registered office mentioned in the document.  When you send in such a
145 complete document, please notify me: kern at sibbald dot com.
146
147
148
149 \section{The Development Cycle}
150 \index{Developement Cycle}
151 \index{Cycle!Developement}
152 \addcontentsline{toc}{subsubsection}{Development Cycle}
153
154 As I noted in the 1.38 ReleaseNotes, version 1.38 was different from prior
155 versions because it had a lot more contributions.  I expect that this trend
156 will continue.  As a consequence, I am going to modify how I normally do
157 development, and instead of making a list of all the features that I will
158 implement in the next version, I will personally sign up for one (maybe
159 two) projects at a time, and when they are complete, I will release a new
160 version.
161
162 The difference is that I will have more time to review the new code that is
163 being contributed, and will be able to devote more time to a smaller number
164 of projects (1.38 had too many new features for me to handle correctly).
165
166 I expect that future release schedules will be much the same, and the
167 number of new features will also be much the same providing that the
168 contributions continue to come -- and they show no signs of let up :-)
169
170 \index{Feature Requests}
171 {\bf Feature Requests:} \\
172 In addition, I would like to "formalize" the feature requests a bit.
173
174 Instead of me maintaining an informal list of everything I run into 
175 (kernstodo), I would like to maintain a "formal" list of projects.  This 
176 means that all new feature requests, including those recently discussed on 
177 the email lists, must be formally submitted and approved. 
178
179 Formal submission of feature requests will take two forms: \\
180 1. non-mandatory, but highly recommended is to discuss proposed new features
181 on the mailing list.\\
182 2.  Formal submission of an Feature Request in a special format.
183 I'll give an example of this below, but you can also find it on the web
184 site under "Support -\gt{} Feature Requests".  Since it takes a bit of time to
185 properly fill out a Feature Request form, you probably should check on the email list
186 first.
187
188 Once the Feature Request is received by the keeper of the projects list, it
189 will be sent to me, and  I will either accept it, send it back
190 asking for clarification, send it to the email list asking for opinions, or
191 reject it.
192
193 If it is accepted, it will go in the "projects" file (a simple ASCII file) 
194 maintained in the main Bacula source directory.
195
196 {\bf Implementation of Feature Requests:}\\
197 Any qualified developer can sign up for a project.  The project must have
198 an entry in the projects file, and the developer's name will appear in the
199 Status field.
200
201 {\bf How Feature Requests are accepted:}\\
202 Acceptance of Feature Requests depends on several things: \\
203 1.  feedback from users.  If it is negative, the Feature Request will probably not be
204 accepted.  \\
205 2.  the difficulty of the project.  A project that is so
206 difficult that I cannot imagine finding someone to implement probably won't
207 be accepted. \\
208  3.  whether or not the Feature Request fits within the
209 current stategy of Bacula (for example an Feature Request that requests changing the
210 tape to tar format would not be accepted, ...)
211
212 {\bf How Feature Requests are prioritized:}\\
213 Once an Feature Request is accepted, it needs to be implemented.  If you
214 can find a developer for it, or one signs up for implementing it, then the
215 Feature Request becomes top priority (at least for that developer).
216
217 Between releases of Bacula, we will generally solicit Feature Request input
218 for the next version, and by way of this email, we suggest that you send
219 discuss and send in your Feature Requests for the next release.  Please
220 verify that the Feature Request is not in the current list (attached to this email).
221
222 Once users have had several weeks to submit Feature Requests, the keeper of the
223 projects list will
224 organize them, and request users to vote on them.  This will allow fixing
225 prioritizing the Feature Requests.  Having a priority is one thing, but
226 getting it implement is another thing -- we are hoping that the Bacula
227 community will take more responsibility for assuring the implementation of
228 accepted Feature Requests.
229
230 Feature Request format:
231 \begin{verbatim}
232 ============= Empty Feature Request form ===========
233 Item n:   One line summary ...
234   Date:   Date submitted
235   Origin: Name and email of originator.
236   Status:
237
238   What:   More detailed explanation ...
239
240   Why:    Why it is important ...
241
242   Notes:  Additional notes or features (omit if not used)
243 ============== End Feature Request form ==============
244 \end{verbatim}
245
246 \begin{verbatim}
247 ============= Example Completed  Feature Request form ===========
248 Item 1:   Implement a Migration job type that will move the job
249           data from one device to another.
250   Origin: Sponsored by Riege Sofware International GmbH. Contact:
251           Daniel Holtkamp <holtkamp at riege dot com>
252   Date:   28 October 2005
253   Status: Partially coded in 1.37 -- much more to do. Assigned to
254           Kern.
255
256   What:   The ability to copy, move, or archive data that is on a
257           device to another device is very important.
258
259   Why:    An ISP might want to backup to disk, but after 30 days
260           migrate the data to tape backup and delete it from
261           disk.  Bacula should be able to handle this
262           automatically.  It needs to know what was put where,
263           and when, and what to migrate -- it is a bit like
264           retention periods.  Doing so would allow space to be
265           freed up for current backups while maintaining older
266           data on tape drives.
267
268   Notes:  Migration could be triggered by:
269            Number of Jobs
270            Number of Volumes
271            Age of Jobs
272            Highwater size (keep total size)
273            Lowwater mark
274 =================================================
275 \end{verbatim}
276
277
278 \section{Bacula Code Submissions and Projects}
279 \index{Submissions and Projects}
280 \addcontentsline{toc}{subsection}{Code Submissions and Projects}
281
282 Getting code implemented in Bacula works roughly as follows:
283
284 \begin{itemize}
285
286 \item Kern is the project manager, but prefers not to be a "gate keeper".
287       This means that the developers are expected to be self-motivated,
288       and once they have experience submit directly to the SVN.  However,
289       it is a good idea to have your patches reviewed prior to submitting,
290       and it is a bad idea to submit monster patches because no one will
291       be able to properly review them. See below for more details on this.
292
293 \item  There are growing numbers of contributions (very good).
294
295 \item Some contributions come in  the form of relatively small patches,
296      which Kern reviews, integrates, documents, tests, and maintains.
297
298 \item All Bacula developers take full
299    responsibility for writing the code, posting as patches so that I can
300    review it as time permits, integrating it at an appropriate time,
301    responding to my requests for tweaking it (name changes, ...),
302    document it in the code, document it in the manual (even though
303    their mother tongue is not English), test it, develop and commit
304    regression scripts, and answer in a timely fashion all bug reports --
305    even occassionally accepting additional bugs :-)
306
307    This is a sustainable way of going forward with Bacula, and the
308    direction that the project will be taking more and more.  For
309    example, in the past, we have had some very dedicated programmers
310    who did major projects. However, these
311    programmers due to outside obligations (job responsibilities change of
312    job, school duties, ...) could not continue to maintain the code.  In
313    those cases, the code suffers from lack of maintenance, sometimes I
314    patch it, sometimes not.  In the end, the code gets dropped from the
315    project (there are two such contributions that are heading in that
316    direction).  When ever possible, we would like to avoid this, and 
317    ensure a continuation of the code and a sharing of the development,
318    debugging, documentation, and maintenance responsibilities.
319 \end{itemize}
320
321 \section{Patches for Released Versions}
322 \index{Patches for Released Versions}
323 \addcontentsline{toc}{subsection}{Patches for Released Versions}
324 If you fix a bug in a released version, you should, unless it is
325 an absolutely trivial bug, create and release a patch file for the
326 bug.  The procedure is as follows:
327
328 Fix the bug in the branch and in the trunk.
329
330 Make a patch file for the branch and add the branch patch to 
331 the patches directory in both the branch and the trunk.
332 The name should be 2.2.4-xxx.patch  where xxx is unique, in this case it can 
333 be "restore", e.g. 2.2.4-restore.patch.  Add to the top of the
334 file  a brief description and instructions for applying it -- see for example 
335 2.2.4-poll-mount.patch.  The best way to create the patch file is as
336 follows:
337
338 \begin{verbatim}
339   (edit) 2.2.4-restore.patch
340   (input description)
341   (end edit)
342
343    svn diff >>2.2.4-restore.patch
344 \end{verbatim}
345
346 check to make sure no extra junk got put into the patch file (i.e.
347 it should have the patch for that bug only).
348
349 If there is not a bug report on the problem, create one, then add the
350 patch to the bug report. 
351
352 Uthen upload it to the 2.2.x release of bacula-patches.
353
354 So, end the end, the patch file is:
355 \begin{itemize}
356 \item Attached to the bug report
357
358 \item In Branch-2.2/bacula/patches/...
359
360 \item In the trunk
361
362 \item Loaded on Source Forge bacula-patches 2.2.x release. When
363    you add it, click on the check box to send an Email so that all the
364    users that are monitoring SF patches get notified.
365 \end{itemize}
366
367
368
369 \section{SVN Usage}
370 \index{SVN Usage}
371 \addcontentsline{toc}{subsection}{SVN Usage}
372
373 Please note that if you are familar with CVS, SVN is very
374 similar (and better), but there can be a few surprising
375 differences.
376
377 The *entire* Bacula  SourceForge.net Subversion repository can be
378 checked out through SVN with the following command:
379
380 \begin{verbatim}
381 svn checkout https://bacula.svn.sourceforge.net/svnroot/bacula bacula
382 \end{verbatim}
383
384 With the above command, you will get everything, which is a very large
385 amount of data:
386
387 \begin{verbatim}
388 branches/
389   Branch-1.32a/
390   ...
391   Branch-2.0/
392   import/
393   vendor/
394 tags/
395   Release-1.1/
396   ...
397   Release-2.0.2/
398 trunk/
399   bacula/
400   docs/
401   gui/
402   regress/
403   rescue/
404 \end{verbatim}
405
406 Note, you should NEVER commit code to any checkout that you have
407 done of a tag.  All tags (e.g. Release-1.1, ... Release-2.0.2) 
408 should be considered read-only.
409
410 You may commit code to the most recent item in
411 branches (in the above the most recent one is Branch-2.0).  If
412 you want to commit code to an older branch, then please contact
413 Kern first.
414
415 You may create your own tags and/or branches, but they should
416 have a name clearly distinctive from Branch-, Release-, or Beta-,
417 which are official names used by the project.  If you create a
418 tag, then you should NEVER commit code to it, for the same 
419 reason noted above -- it should serve as a marker for something
420 you released.  If you create a branch, then you are free to
421 commit to it as you wish.
422
423 You may, of course, commit to the trunk.
424
425 In summary:
426
427 \begin{verbatim}
428 branches
429   Branch-nnn
430 tags
431   Release-nnn
432   Beta-nnn
433 \end{verbatim}
434
435 are reserved names to be created only by the project manager (or
436 with his OK), where the nnn is any sequence of numbers and
437 periods (e.g. 2.0, 2.0.1, ...).  
438
439 In addition all tags even those that you create are read-only
440 forever. Typically tags represent release points either in the
441 trunc or in a branch.
442
443
444 Coming back to getting source code. 
445 If you only want the current Bacula source code, you could use:
446
447 \begin{verbatim}
448 svn checkout https://bacula.svn.sourceforge.net/svnroot/bacula/trunk/bacula bacula
449 \end{verbatim}
450
451 To view what is in the SVN, point your browser at the following URL:
452 http://bacula.svn.sourceforge.net/viewvc/bacula/  
453
454 Many of the Subversion (svn) commands are almost identical to those that
455 you have used for cvs, but some (such as a checkout) can have surprising
456 results, so you should take a careful look at the documentation. 
457
458 Robert has kindly provided the following documentation on the new
459 svn repository and how to use it:
460
461 Here is the list of branches:
462 \begin{verbatim}
463         Branch-1.32a
464         Branch-1.32e
465         Branch-1.34.2
466         Branch-1.34.5
467         Branch-1.36
468         Branch-1.36.1
469         Branch-1.36.2
470         Branch-1.38
471         Branch-2.0
472         import
473         vendor
474 \end{verbatim}
475
476 The list of tags is:
477 \begin{verbatim}
478         Release-1.1     Release-1.19    Release-1.19a   Release-1.19b
479         Release-1.20    Release-1.21    Release-1.22    Release-1.23
480         Release-1.23a   Release-1.24    Release-1.25    Release-1.25a
481         Release-1.26    Release-1.27    Release-1.27a   Release-1.27b
482         Release-1.27c   Release-1.28    Release-1.29    Release-1.30
483         Release-1.31    Release-1.31a   Release-1.32    Release-1.32a
484         Release-1.32b   Release-1.32c   Release-1.32d   Release-1.32e
485         Release-1.32f   Release-1.32f-2 Release-1.32f-3 Release-1.32f-4
486         Release-1.32f-5 Release-1.34.0  Release-1.34.1  Release-1.34.3
487         Release-1.34.4  Release-1.34.5  Release-1.34.6  Release-1.35.1
488         Release-1.35.2  Release-1.35.3  Release-1.35.6  Release-1.35.7
489         Release-1.35.8  Release-1.36.0  Release-1.36.1  Release-1.36.2
490         Release-1.36.3  Release-1.38.0  Release-1.38.1  Release-1.38.10
491         Release-1.38.11 Release-1.38.2  Release-1.38.3  Release-1.38.4
492         Release-1.38.5  Release-1.38.6  Release-1.38.7  Release-1.38.8
493         Release-1.38.9  Release-1.8.1   Release-1.8.2   Release-1.8.3
494         Release-1.8.4   Release-1.8.5   Release-1.8.6   Release-2.0.0
495         Release-2.0.1   Release-2.0.2
496 \end{verbatim}
497
498 Here is a list of commands to get you started.  The recommended book is
499 "Version Control with Subversion", by Ben Collins-Sussmann,
500 Brian W. Fitzpatrick, and Michael Pilato, O'Reilly.  The book is
501 Open Source, so it is also available on line at:
502
503 \begin{verbatim}
504    http://svnbook.red-bean.com
505 \end{verbatim}
506
507 Get a list of commands
508
509 \begin{verbatim}
510    svn help
511 \end{verbatim}
512
513 Get a help with a command
514
515 \begin{verbatim}
516    svn help command
517 \end{verbatim}
518
519 Checkout the HEAD revision of all modules from the project into the
520 directory bacula-new
521
522 \begin{verbatim}
523    svn co https://bacula.svn.sourceforge.net/svnroot/bacula/trunk bacula.new
524 \end{verbatim}
525
526 Checkout the HEAD revision of the bacula module into the bacula subdirectory
527
528 \begin{verbatim}
529    svn checkout https://bacula.svn.sourceforge.net/svnroot/bacula/trunk/bacula
530 \end{verbatim}
531
532 See which files have changed in the working copy
533
534 \begin{verbatim}
535    svn status
536 \end{verbatim}
537
538 See which files are out of date
539
540 \begin{verbatim}
541    svn status -u
542 \end{verbatim}
543
544 Add a new file file.c
545
546 \begin{verbatim}
547    svn add file.c
548 \end{verbatim}
549
550 Create a new directory
551
552 \begin{verbatim}
553    svn mkdir newdir
554 \end{verbatim}
555
556 Delete an obsolete file
557
558 \begin{verbatim}
559    svn delete file.c
560 \end{verbatim}
561
562 Rename a file
563
564 \begin{verbatim}
565    svn move file.c newfile.c
566 \end{verbatim}
567
568 Move a file to a new location
569
570 \begin{verbatim}
571    svn move file.c ../newdir/file.c
572 \end{verbatim}
573
574 Copy a file retaining the original history in the new file
575
576 \begin{verbatim}
577    svn copy file.c newfile.c
578 \end{verbatim}
579
580 Update the working copy with the outstanding changes
581
582 \begin{verbatim}
583    svn update
584 \end{verbatim}
585
586 Compare working copy with the repository
587
588 \begin{verbatim}
589    svn diff file.c
590 \end{verbatim}
591
592 Commit the changes in the local working copy
593
594 \begin{verbatim}
595    svn commit
596 \end{verbatim}
597
598 Specify which files are ignored in the current directory
599
600 \begin{verbatim}
601    svn propedit svn:ignore .
602 \end{verbatim}
603
604 Mark a file to be executable
605
606 \begin{verbatim}
607    svn propset svn:executable '*' prog.sh
608 \end{verbatim}
609
610 Unmark a file as executable
611
612 \begin{verbatim}
613    svn propdel svn:executable prog.sh
614 \end{verbatim}
615
616 List a file's properties
617
618 \begin{verbatim}
619    svn proplist file.c
620 \end{verbatim}
621
622 Create a branch for a new version
623
624 \begin{verbatim}
625    svn copy https://bacula.svn.sourceforge.net/svnroot/bacula/trunk \
626           https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.1
627 \end{verbatim}
628
629 Tag a version for a new release
630
631 \begin{verbatim}
632    svn copy https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.1 \
633           https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Release-2.1
634 \end{verbatim}
635
636
637 Let's say you are working in the directory scripts.  You would then do:
638
639 \begin{verbatim}
640 cd scripts
641 (edit some files)
642 \end{verbatim}
643
644 when you are happy with your changes, you can do the following:
645
646 \begin{verbatim}
647 cd bacula   (to your top level directory)
648 svn diff  my-changes.patch
649 \end{verbatim}
650
651 When the command is done, you can look in the file my-changes.patch
652 and you will see all the changes you have made to your copy of the
653 repository.  Make sure that you understand all the changes that
654 it reports before proceeding.  If you modified files that you do
655 do not want to commit to the main repository, you can simply delete
656 them from your local directory, and they will be restored from the
657 repository with the "svn update" that is shown below.  Normally, you
658 should not find changes to files that you do not want to commit, and
659 if you find yourself in that position a lot, you are probably doing
660 something wrong.
661
662 Let's assume that now you want to commit your changes to the main
663 SVN repository.
664
665 First do:
666
667 \begin{verbatim}
668 cd bacula
669 svn update
670 \end{verbatim}
671
672 When you do this, it will pull any changes made by other developers into
673 your local copy of the repository, and it will check for conflicts. If there
674 are any, it will tell you, and you will need to resolve them.  The problems
675 of resolving conflicts are a bit more than this document can cover, but
676 you can examine the files it claims have conflicts and look for \lt{}\lt{}\lt{}\lt{}
677 or look in the .rej files that it creates.  If you have problems, just ask
678 on the developer's list.
679
680 Note, doing the above "svn update" is not absolutely necessary.  There are
681 times when you may be working on code and you want to commit it, but you
682 explicitly do not want to move up to the latest version of the code in
683 the SVN.  If that is the case, you can simply skip the "svn update" and
684 do the commit shown below.  If the commit fails because of a conflict, it
685 will tell you, and you must resolve the conflict before it will permit
686 you to do the commit.
687
688 Once your local copy of the repository has been updated, you can now
689 commit your changes:
690
691 \begin{verbatim}
692 svn commit -m "Some comment about what you changed"
693 \end{verbatim}
694
695 or if you really only want to commit a single file, you can
696 do:
697
698 \begin{verbatim}
699 svn commit -m "comment" scripts/file-I-edited
700 \end{verbatim}
701
702 Note, if you have done a build in your directory, or you have added
703 other new files, the commit will update only the files that are
704 actually in the repository.  For example, none of the object files
705 are stored in the repository, so when you do a commit, those object
706 files will simply be ignored.
707
708 If you want to add new files or remove files from the main SVN
709 repository, and you are not experienced with SVN, please ask Kern
710 to do it.  If you follow the simple steps above, it is unlikely that
711 you will do any damage to the repository, and if you do, it is always
712 possible for us to recover, but it can be painful.
713
714 If you are only working in one subdirectory of say the bacula project,
715 for example, the scripts directory, you can do your commit from
716 that subdirectory, and only the changes in that directory and all its
717 subdirectories will be committed.  This can be helpful for translators.
718 If you are doing a French translation, you will be working in
719 docs/manual-fr, and if you are always cd'ed into that directory when
720 doing your commits, your commit will effect only that directory.  As
721 long as you are careful only to change files that you want changed,
722 you have little to worry about.
723
724 \section{Subversion Resources}
725 \index{Subversion (svn) Resources}
726 \addcontentsline{toc}{subsection}{Subversion Resources}
727
728 \begin{verbatim}
729 cvs2svn Statistics:
730 ------------------
731 Total CVS Files:              3286
732 Total CVS Revisions:         28924
733 Total Unique Tags:              63
734 Total Unique Branches:          11
735 CVS Repos Size in KB:       232421
736 Total SVN Commits:            4116
737 First Revision Date:    Tue Apr 23 12:42:57 2002
738 Last Revision Date:     Tue Feb  6 06:37:57 2007
739 \end{verbatim}
740
741 The new Subversion repository size on Robert's machine:
742
743 \begin{verbatim}
744 4.0K    bacula-tst/dav
745 12K     bacula-tst/locks
746 40K     bacula-tst/hooks
747 16K     bacula-tst/conf
748 190M    bacula-tst/db/revs
749 17M     bacula-tst/db/revprops
750 4.0K    bacula-tst/db/transactions
751 206M    bacula-tst/db
752 206M    bacula-tst
753 \end{verbatim}
754
755
756 Main Subversion Web Page
757 \elink{http://subversion.tigris.org}{http://subversion.tigris.org}
758
759 Subversion Book
760 \elink{http://svnbook.red-bean.com}{http://svnbook.red-bean.com}
761
762 Subversion Clients
763 \elink{http://subversion.tigris.org/project\_packages.html}{http://subversion.tigris.org/project\_packages.html}
764
765  (For Windows users the TortoiseSVN package is awesome)
766
767 GUI UNIX client link
768 \elink{http://rapidsvn.tigris.org/}{http://rapidsvn.tigris.org/}
769
770 A nice KDE GUI client:
771 kdesvn
772
773
774
775 \section{Developing Bacula}
776 \index{Developing Bacula}
777 \index{Bacula!Developing}
778 \addcontentsline{toc}{subsubsection}{Developing Bacula}
779
780 Typically the simplest way to develop Bacula is to open one xterm window
781 pointing to the source directory you wish to update; a second xterm window at
782 the top source directory level, and a third xterm window at the bacula
783 directory \lt{}top\gt{}/src/bacula. After making source changes in one of the
784 directories, in the top source directory xterm, build the source, and start
785 the daemons by entering: 
786
787 make and 
788
789 ./startit then in the enter: 
790
791 ./console or 
792
793 ./gnome-console to start the Console program. Enter any commands for testing.
794 For example: run kernsverify full. 
795
796 Note, the instructions here to use {\bf ./startit} are different from using a
797 production system where the administrator starts Bacula by entering {\bf
798 ./bacula start}. This difference allows a development version of {\bf Bacula}
799 to be run on a computer at the same time that a production system is running.
800 The {\bf ./startit} strip starts {\bf Bacula} using a different set of
801 configuration files, and thus permits avoiding conflicts with any production
802 system. 
803
804 To make additional source changes, exit from the Console program, and in the
805 top source directory, stop the daemons by entering: 
806
807 ./stopit then repeat the process. 
808
809 \subsection{Debugging}
810 \index{Debugging}
811 \addcontentsline{toc}{subsubsection}{Debugging}
812
813 Probably the first thing to do is to turn on debug output. 
814
815 A good place to start is with a debug level of 20 as in {\bf ./startit -d20}.
816 The startit command starts all the daemons with the same debug level.
817 Alternatively, you can start the appropriate daemon with the debug level you
818 want. If you really need more info, a debug level of 60 is not bad, and for
819 just about everything a level of 200. 
820
821 \subsection{Using a Debugger}
822 \index{Using a Debugger}
823 \index{Debugger!Using a}
824 \addcontentsline{toc}{subsubsection}{Using a Debugger}
825
826 If you have a serious problem such as a segmentation fault, it can usually be
827 found quickly using a good multiple thread debugger such as {\bf gdb}. For
828 example, suppose you get a segmentation violation in {\bf bacula-dir}. You
829 might use the following to find the problem: 
830
831 \lt{}start the Storage and File daemons\gt{}
832 cd dird
833 gdb ./bacula-dir
834 run -f -s -c ./dird.conf
835 \lt{}it dies with a segmentation fault\gt{}
836 where
837 The {\bf -f} option is specified on the {\bf run} command to inhibit {\bf
838 dird} from going into the background. You may also want to add the {\bf -s}
839 option to the run command to disable signals which can potentially interfere
840 with the debugging. 
841
842 As an alternative to using the debugger, each {\bf Bacula} daemon has a built
843 in back trace feature when a serious error is encountered. It calls the
844 debugger on itself, produces a back trace, and emails the report to the
845 developer. For more details on this, please see the chapter in the main Bacula
846 manual entitled ``What To Do When Bacula Crashes (Kaboom)''. 
847
848 \subsection{Memory Leaks}
849 \index{Leaks!Memory}
850 \index{Memory Leaks}
851 \addcontentsline{toc}{subsubsection}{Memory Leaks}
852
853 Because Bacula runs routinely and unattended on client and server machines, it
854 may run for a long time. As a consequence, from the very beginning, Bacula
855 uses SmartAlloc to ensure that there are no memory leaks. To make detection of
856 memory leaks effective, all Bacula code that dynamically allocates memory MUST
857 have a way to release it. In general when the memory is no longer needed, it
858 should be immediately released, but in some cases, the memory will be held
859 during the entire time that Bacula is executing. In that case, there MUST be a
860 routine that can be called at termination time that releases the memory. In
861 this way, we will be able to detect memory leaks. Be sure to immediately
862 correct any and all memory leaks that are printed at the termination of the
863 daemons. 
864
865 \subsection{Special Files}
866 \index{Files!Special}
867 \index{Special Files}
868 \addcontentsline{toc}{subsubsection}{Special Files}
869
870 Kern uses files named 1, 2, ... 9 with any extension as scratch files. Thus
871 any files with these names are subject to being rudely deleted at any time. 
872
873 \subsection{When Implementing Incomplete Code}
874 \index{Code!When Implementing Incomplete}
875 \index{When Implementing Incomplete Code}
876 \addcontentsline{toc}{subsubsection}{When Implementing Incomplete Code}
877
878 Please identify all incomplete code with a comment that contains 
879
880 \begin{verbatim}
881 ***FIXME***
882 \end{verbatim} 
883
884 where there are three asterisks (*) before and after the word
885 FIXME (in capitals) and no intervening spaces. This is important as it allows
886 new programmers to easily recognize where things are partially implemented. 
887
888 \subsection{Bacula Source File Structure}
889 \index{Structure!Bacula Source File}
890 \index{Bacula Source File Structure}
891 \addcontentsline{toc}{subsubsection}{Bacula Source File Structure}
892
893 The distribution generally comes as a tar file of the form {\bf
894 bacula.x.y.z.tar.gz} where x, y, and z are the version, release, and update
895 numbers respectively. 
896
897 Once you detar this file, you will have a directory structure as follows: 
898
899 \footnotesize
900 \begin{verbatim}
901 |
902 Tar file:
903 |- depkgs
904    |- mtx              (autochanger control program + tape drive info)
905    |- sqlite           (SQLite database program)
906
907 Tar file:
908 |- depkgs-win32
909    |- pthreads         (Native win32 pthreads library -- dll)
910    |- zlib             (Native win32 zlib library)
911    |- wx               (wxWidgets source code)
912
913 Project bacula:
914 |- bacula              (main source directory containing configuration
915    |                    and installation files)
916    |- autoconf         (automatic configuration files, not normally used
917    |                    by users)
918    |- intl             (programs used to translate)
919    |- platforms        (OS specific installation files)
920       |- redhat        (Red Hat installation)
921       |- solaris       (Sun installation)
922       |- freebsd       (FreeBSD installation)
923       |- irix          (Irix installation -- not tested)
924       |- unknown       (Default if system not identified)
925    |- po               (translations of source strings)
926    |- src              (source directory; contains global header files)
927       |- cats          (SQL catalog database interface directory)
928       |- console       (bacula user agent directory)
929       |- dird          (Director daemon)
930       |- filed         (Unix File daemon)
931          |- win32      (Win32 files to make bacula-fd be a service)
932       |- findlib       (Unix file find library for File daemon)
933       |- gnome-console (GNOME version of console program)
934       |- lib           (General Bacula library)
935       |- stored        (Storage daemon)
936       |- tconsole      (Tcl/tk console program -- not yet working)
937       |- testprogs     (test programs -- normally only in Kern's tree)
938       |- tools         (Various tool programs)
939       |- win32         (Native Win32 File daemon)
940          |- baculafd   (Visual Studio project file)
941          |- compat     (compatibility interface library)
942          |- filed      (links to src/filed)
943          |- findlib    (links to src/findlib)
944          |- lib        (links to src/lib)
945          |- console    (beginning of native console program)
946          |- wx-console (wxWidget console Win32 specific parts)
947      |- wx-console     (wxWidgets console main source program)
948
949 Project regress:
950 |- regress             (Regression scripts)
951    |- bin              (temporary directory to hold Bacula installed binaries)
952    |- build            (temporary directory to hold Bacula source)
953    |- scripts          (scripts and .conf files)
954    |- tests            (test scripts)
955    |- tmp              (temporary directory for temp files)
956    |- working          (temporary working directory for Bacula daemons)
957
958 Project docs:
959 |- docs                (documentation directory)
960    |- developers       (Developer's guide)
961    |- home-page        (Bacula's home page source)
962    |- manual           (html document directory)
963    |- manual-fr        (French translation) 
964    |- manual-de        (German translation) 
965    |- techlogs         (Technical development notes);
966
967 Project rescue:
968 |- rescue              (Bacula rescue CDROM)
969    |- linux            (Linux rescue CDROM)
970       |- cdrom         (Linux rescue CDROM code)
971         ...
972    |- solaris          (Solaris rescue -- incomplete) 
973    |- freebsd          (FreeBSD rescue -- incomplete)
974
975 Project gui:
976 |- gui                 (Bacula GUI projects)
977   |- bacula-web        (Bacula web php management code)
978   |- bimagemgr         (Web application for burning CDROMs)
979
980
981 \end{verbatim}
982 \normalsize
983
984 \subsection{Header Files}
985 \index{Header Files}
986 \index{Files!Header}
987 \addcontentsline{toc}{subsubsection}{Header Files}
988
989 Please carefully follow the scheme defined below as it permits in general only
990 two header file includes per C file, and thus vastly simplifies programming.
991 With a large complex project like Bacula, it isn't always easy to ensure that
992 the right headers are invoked in the right order (there are a few kludges to
993 make this happen -- i.e. in a few include files because of the chicken and egg
994 problem, certain references to typedefs had to be replaced with {\bf void} ). 
995
996 Every file should include {\bf bacula.h}. It pulls in just about everything,
997 with very few exceptions. If you have system dependent ifdefing, please do it
998 in {\bf baconfig.h}. The version number and date are kept in {\bf version.h}. 
999
1000 Each of the subdirectories (console, cats, dird, filed, findlib, lib, stored,
1001 ...) contains a single directory dependent include file generally the name of
1002 the directory, which should be included just after the include of {\bf
1003 bacula.h}. This file (for example, for the dird directory, it is {\bf dird.h})
1004 contains either definitions of things generally needed in this directory, or
1005 it includes the appropriate header files. It always includes {\bf protos.h}.
1006 See below. 
1007
1008 Each subdirectory contains a header file named {\bf protos.h}, which contains
1009 the prototypes for subroutines exported by files in that directory. {\bf
1010 protos.h} is always included by the main directory dependent include file. 
1011
1012 \subsection{Programming Standards}
1013 \index{Standards!Programming}
1014 \index{Programming Standards}
1015 \addcontentsline{toc}{subsubsection}{Programming Standards}
1016
1017 For the most part, all code should be written in C unless there is a burning
1018 reason to use C++, and then only the simplest C++ constructs will be used.
1019 Note, Bacula is slowly evolving to use more and more C++. 
1020
1021 Code should have some documentation -- not a lot, but enough so that I can
1022 understand it. Look at the current code, and you will see that I document more
1023 than most, but am definitely not a fanatic. 
1024
1025 I prefer simple linear code where possible. Gotos are strongly discouraged
1026 except for handling an error to either bail out or to retry some code, and
1027 such use of gotos can vastly simplify the program. 
1028
1029 Remember this is a C program that is migrating to a {\bf tiny} subset of C++,
1030 so be conservative in your use of C++ features. 
1031
1032 \subsection{Do Not Use}
1033 \index{Use!Do Not}
1034 \index{Do Not Use}
1035 \addcontentsline{toc}{subsubsection}{Do Not Use}
1036
1037 \begin{itemize}
1038  \item STL -- it is totally incomprehensible. 
1039 \end{itemize}
1040
1041 \subsection{Avoid if Possible}
1042 \index{Possible!Avoid if}
1043 \index{Avoid if Possible}
1044 \addcontentsline{toc}{subsubsection}{Avoid if Possible}
1045
1046 \begin{itemize}
1047 \item Using {\bf void *} because this generally means that one must
1048    using casting, and in C++ casting is rather ugly.  It is OK to use
1049    void * to pass structure address where the structure is not known  
1050    to the routines accepting the packet (typically callback routines).
1051    However, declaring "void *buf" is a bad idea.  Please use the
1052    correct types whenever possible.
1053
1054 \item Using undefined storage specifications such as (short, int, long,
1055    long long, size\_t ...).  The problem with all these is that the number of bytes
1056    they allocate depends on the compiler and the system.  Instead use
1057    Bacula's types (int8\_t, uint8\_t, int32\_t, uint32\_t, int64\_t, and 
1058    uint64\_t).  This guarantees that the variables are given exactly the
1059    size you want. Please try at all possible to avoid using size\_t ssize\_t
1060    and the such. They are very system dependent.  However, some system
1061    routines may need them, so their use is often unavoidable.
1062
1063 \item Returning a malloc'ed buffer from a subroutine --  someone will forget
1064    to release it. 
1065
1066 \item Heap allocation (malloc) unless needed -- it is expensive. Use
1067       POOL\_MEM instead.
1068
1069 \item Templates -- they can create portability problems. 
1070
1071 \item Fancy or tricky C or C++ code, unless you give a  good explanation of
1072    why you used it. 
1073
1074 \item Too much inheritance -- it can complicate the code,  and make reading it
1075    difficult (unless you are in love  with colons) 
1076
1077 \end{itemize}
1078
1079 \subsection{Do Use Whenever Possible}
1080 \index{Possible!Do Use Whenever}
1081 \index{Do Use Whenever Possible}
1082 \addcontentsline{toc}{subsubsection}{Do Use Whenever Possible}
1083
1084 \begin{itemize}
1085 \item Locking and unlocking within a single subroutine.  
1086
1087 \item A single point of exit from all subroutines. A goto is 
1088      perfectly OK to use to get out early, but only to a label
1089      named bail\_out, and possibly an ok\_out.  See current code
1090      examples.
1091
1092 \item Malloc and free within a single subroutine.  
1093
1094 \item Comments and global explanations on what your code or  algorithm does. 
1095
1096 \end{itemize}
1097
1098 \subsection{Indenting Standards}
1099 \index{Standards!Indenting}
1100 \index{Indenting Standards}
1101 \addcontentsline{toc}{subsubsection}{Indenting Standards}
1102
1103 I cannot stand code indented 8 columns at a time. This makes the code
1104 unreadable. Even 4 at a time uses a lot of space, so I have adopted indenting
1105 3 spaces at every level. Note, indention is the visual appearance of the
1106 source on the page, while tabbing is replacing a series of up to 8 spaces from
1107 a tab character. 
1108
1109 The closest set of parameters for the Linux {\bf indent} program that will
1110 produce reasonably indented code are: 
1111
1112 \footnotesize
1113 \begin{verbatim}
1114 -nbad -bap -bbo -nbc -br -brs -c36 -cd36 -ncdb -ce -ci3 -cli0
1115 -cp36 -d0 -di1 -ndj -nfc1 -nfca -hnl -i3 -ip0 -l85 -lp -npcs
1116 -nprs -npsl -saf -sai -saw -nsob -nss -nbc -ncs -nbfda
1117 \end{verbatim}
1118 \normalsize
1119
1120 You can put the above in your .indent.pro file, and then just invoke indent on
1121 your file. However, be warned. This does not produce perfect indenting, and it
1122 will mess up C++ class statements pretty badly. 
1123
1124 Braces are required in all if statements (missing in some very old code). To
1125 avoid generating too many lines, the first brace appears on the first line
1126 (e.g. of an if), and the closing brace is on a line by itself. E.g. 
1127
1128 \footnotesize
1129 \begin{verbatim}
1130    if (abc) {
1131       some_code;
1132   }
1133 \end{verbatim}
1134 \normalsize
1135
1136 Just follow the convention in the code. Originally I indented case clauses
1137 under a switch(), but now I prefer non-indented cases. 
1138
1139 \footnotesize
1140 \begin{verbatim}
1141    switch (code) {
1142    case 'A':
1143       do something
1144       break;
1145    case 'B':
1146       again();
1147       break;
1148    default:
1149       break;
1150   }
1151 \end{verbatim}
1152 \normalsize
1153
1154 Avoid using // style comments except for temporary code or turning off debug
1155 code. Standard C comments are preferred (this also keeps the code closer to
1156 C). 
1157
1158 Attempt to keep all lines less than 85 characters long so that the whole line
1159 of code is readable at one time. This is not a rigid requirement. 
1160
1161 Always put a brief description at the top of any new file created describing
1162 what it does and including your name and the date it was first written. Please
1163 don't forget any Copyrights and acknowledgments if it isn't 100\% your code.
1164 Also, include the Bacula copyright notice that is in {\bf src/c}. 
1165
1166 In general you should have two includes at the top of the an include for the
1167 particular directory the code is in, for includes are needed, but this should
1168 be rare. 
1169
1170 In general (except for self-contained packages), prototypes should all be put
1171 in {\bf protos.h} in each directory. 
1172
1173 Always put space around assignment and comparison operators. 
1174
1175 \footnotesize
1176 \begin{verbatim}
1177    a = 1;
1178    if (b >= 2) {
1179      cleanup();
1180   }
1181 \end{verbatim}
1182 \normalsize
1183
1184 but your can compress things in a {\bf for} statement: 
1185
1186 \footnotesize
1187 \begin{verbatim}
1188    for (i=0; i < del.num_ids; i++) {
1189     ...
1190 \end{verbatim}
1191 \normalsize
1192
1193 Don't overuse the inline if (?:). A full {\bf if} is preferred, except in a
1194 print statement, e.g.: 
1195
1196 \footnotesize
1197 \begin{verbatim}
1198    if (ua->verbose \&& del.num_del != 0) {
1199       bsendmsg(ua, _("Pruned %d %s on Volume %s from catalog.\n"), del.num_del,
1200          del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName);
1201   }
1202 \end{verbatim}
1203 \normalsize
1204
1205 Leave a certain amount of debug code (Dmsg) in code you submit, so that future
1206 problems can be identified. This is particularly true for complicated code
1207 likely to break. However, try to keep the debug code to a minimum to avoid
1208 bloating the program and above all to keep the code readable. 
1209
1210 Please keep the same style in all new code you develop. If you include code
1211 previously written, you have the option of leaving it with the old indenting
1212 or re-indenting it. If the old code is indented with 8 spaces, then please
1213 re-indent it to Bacula standards. 
1214
1215 If you are using {\bf vim}, simply set your tabstop to 8 and your shiftwidth
1216 to 3. 
1217
1218 \subsection{Tabbing}
1219 \index{Tabbing}
1220 \addcontentsline{toc}{subsubsection}{Tabbing}
1221
1222 Tabbing (inserting the tab character in place of spaces) is as normal on all
1223 Unix systems -- a tab is converted space up to the next column multiple of 8.
1224 My editor converts strings of spaces to tabs automatically -- this results in
1225 significant compression of the files. Thus, you can remove tabs by replacing
1226 them with spaces if you wish. Please don't confuse tabbing (use of tab
1227 characters) with indenting (visual alignment of the code). 
1228
1229 \subsection{Don'ts}
1230 \index{Don'ts}
1231 \addcontentsline{toc}{subsubsection}{Don'ts}
1232
1233 Please don't use: 
1234
1235 \footnotesize
1236 \begin{verbatim}
1237 strcpy()
1238 strcat()
1239 strncpy()
1240 strncat();
1241 sprintf()
1242 snprintf()
1243 \end{verbatim}
1244 \normalsize
1245
1246 They are system dependent and un-safe. These should be replaced by the Bacula
1247 safe equivalents: 
1248
1249 \footnotesize
1250 \begin{verbatim}
1251 char *bstrncpy(char *dest, char *source, int dest_size);
1252 char *bstrncat(char *dest, char *source, int dest_size);
1253 int bsnprintf(char *buf, int32_t buf_len, const char *fmt, ...);
1254 int bvsnprintf(char *str, int32_t size, const char  *format, va_list ap);
1255 \end{verbatim}
1256 \normalsize
1257
1258 See src/lib/bsys.c for more details on these routines. 
1259
1260 Don't use the {\bf \%lld} or the {\bf \%q} printf format editing types to edit
1261 64 bit integers -- they are not portable. Instead, use {\bf \%s} with {\bf
1262 edit\_uint64()}. For example: 
1263
1264 \footnotesize
1265 \begin{verbatim}
1266    char buf[100];
1267    uint64_t num = something;
1268    char ed1[50];
1269    bsnprintf(buf, sizeof(buf), "Num=%s\n", edit_uint64(num, ed1));
1270 \end{verbatim}
1271 \normalsize
1272
1273 The edit buffer {\bf ed1} must be at least 27 bytes long to avoid overflow.
1274 See src/lib/edit.c for more details. If you look at the code, don't start
1275 screaming that I use {\bf lld}. I actually use subtle trick taught to me by
1276 John Walker. The {\bf lld} that appears in the editing routine is actually
1277 {\bf \#define} to a what is needed on your OS (usually ``lld'' or ``q'') and
1278 is defined in autoconf/configure.in for each OS. C string concatenation causes
1279 the appropriate string to be concatenated to the ``\%''. 
1280
1281 Also please don't use the STL or Templates or any complicated C++ code. 
1282
1283 \subsection{Message Classes}
1284 \index{Classes!Message}
1285 \index{Message Classes}
1286 \addcontentsline{toc}{subsubsection}{Message Classes}
1287
1288 Currently, there are five classes of messages: Debug, Error, Job, Memory, 
1289 and Queued.
1290
1291 \subsection{Debug Messages}
1292 \index{Messages!Debug}
1293 \index{Debug Messages}
1294 \addcontentsline{toc}{subsubsection}{Debug Messages}
1295
1296 Debug messages are designed to be turned on at a specified debug level and are
1297 always sent to STDOUT. There are designed to only be used in the development
1298 debug process. They are coded as: 
1299
1300 DmsgN(level, message, arg1, ...) where the N is a number indicating how many
1301 arguments are to be substituted into the message (i.e. it is a count of the
1302 number arguments you have in your message -- generally the number of percent
1303 signs (\%)). {\bf level} is the debug level at which you wish the message to
1304 be printed. message is the debug message to be printed, and arg1, ... are the
1305 arguments to be substituted. Since not all compilers support \#defines with
1306 varargs, you must explicitly specify how many arguments you have. 
1307
1308 When the debug message is printed, it will automatically be prefixed by the
1309 name of the daemon which is running, the filename where the Dmsg is, and the
1310 line number within the file. 
1311
1312 Some actual examples are: 
1313
1314 Dmsg2(20, ``MD5len=\%d MD5=\%s\textbackslash{}n'', strlen(buf), buf); 
1315
1316 Dmsg1(9, ``Created client \%s record\textbackslash{}n'', client->hdr.name); 
1317
1318 \subsection{Error Messages}
1319 \index{Messages!Error}
1320 \index{Error Messages}
1321 \addcontentsline{toc}{subsubsection}{Error Messages}
1322
1323 Error messages are messages that are related to the daemon as a whole rather
1324 than a particular job. For example, an out of memory condition my generate an
1325 error message. They should be very rarely needed. In general, you should be
1326 using Job and Job Queued messages (Jmsg and Qmsg). They are coded as: 
1327
1328 EmsgN(error-code, level, message, arg1, ...) As with debug messages, you must
1329 explicitly code the of arguments to be substituted in the message. error-code
1330 indicates the severity or class of error, and it may be one of the following: 
1331
1332 \addcontentsline{lot}{table}{Message Error Code Classes}
1333 \begin{longtable}{lp{3in}}
1334 {{\bf M\_ABORT} } & {Causes the daemon to immediately abort. This should be
1335 used only  in extreme cases. It attempts to produce a  traceback. } \\
1336 {{\bf M\_ERROR\_TERM} } & {Causes the daemon to immediately terminate. This
1337 should be used only  in extreme cases. It does not produce a  traceback. } \\
1338 {{\bf M\_FATAL} } & {Causes the daemon to terminate the current job, but the
1339 daemon keeps running } \\
1340 {{\bf M\_ERROR} } & {Reports the error. The daemon and the job continue
1341 running } \\
1342 {{\bf M\_WARNING} } & {Reports an warning message. The daemon and the job
1343 continue running } \\
1344 {{\bf M\_INFO} } & {Reports an informational message.}
1345
1346 \end{longtable}
1347
1348 There are other error message classes, but they are in a state of being
1349 redesigned or deprecated, so please do not use them. Some actual examples are:
1350
1351
1352 Emsg1(M\_ABORT, 0, ``Cannot create message thread: \%s\textbackslash{}n'',
1353 strerror(status)); 
1354
1355 Emsg3(M\_WARNING, 0, ``Connect to File daemon \%s at \%s:\%d failed. Retrying
1356 ...\textbackslash{}n'',  client-\gt{}hdr.name, client-\gt{}address,
1357 client-\gt{}port); 
1358
1359 Emsg3(M\_FATAL, 0, ``bdird\lt{}filed: bad response from Filed to \%s command:
1360 \%d \%s\textbackslash{}n'',  cmd, n, strerror(errno)); 
1361
1362 \subsection{Job Messages}
1363 \index{Job Messages}
1364 \index{Messages!Job}
1365 \addcontentsline{toc}{subsubsection}{Job Messages}
1366
1367 Job messages are messages that pertain to a particular job such as a file that
1368 could not be saved, or the number of files and bytes that were saved. They
1369 Are coded as:
1370 \begin{verbatim}
1371 Jmsg(jcr, M\_FATAL, 0, "Text of message");
1372 \end{verbatim}
1373 A Jmsg with M\_FATAL will fail the job. The Jmsg() takes varargs so can
1374 have any number of arguments for substituted in a printf like format.
1375 Output from the Jmsg() will go to the Job report.
1376 <br>
1377 If the Jmsg is followed with a number such as Jmsg1(...), the number
1378 indicates the number of arguments to be substituted (varargs is not
1379 standard for \#defines), and what is more important is that the file and
1380 line number will be prefixed to the message. This permits a sort of debug
1381 from user's output.
1382
1383 \subsection{Queued Job Messages}
1384 \index{Queued Job Messages}
1385 \index{Messages!Job}
1386 \addcontentsline{toc}{subsubsection}{Queued Job Messages}
1387 Queued Job messages are similar to Jmsg()s except that the message is
1388 Queued rather than immediately dispatched. This is necessary within the
1389 network subroutines and in the message editing routines. This is to prevent
1390 recursive loops, and to ensure that messages can be delivered even in the
1391 event of a network error.
1392
1393
1394 \subsection{Memory Messages}
1395 \index{Messages!Memory}
1396 \index{Memory Messages}
1397 \addcontentsline{toc}{subsubsection}{Memory Messages}
1398
1399 Memory messages are messages that are edited into a memory buffer. Generally
1400 they are used in low level routines such as the low level device file dev.c in
1401 the Storage daemon or in the low level Catalog routines. These routines do not
1402 generally have access to the Job Control Record and so they return error
1403 essages reformatted in a memory buffer. Mmsg() is the way to do this.