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