]> git.sur5r.net Git - bacula/docs/blob - docs/manual-fr/generaldevel.tex
Mise a jour de dirddconf.tex. Debut de filedconf.tex.
[bacula/docs] / docs / manual-fr / 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
25 The second class of contributions are those which will be integrated with
26 Bacula and become an essential part. Within this class of contributions, there
27 are two hurdles to surmount. One is getting your patch accepted, and two is
28 dealing with copyright issues. The rest of this document describes some of the
29 requirements for such code. 
30
31 \subsubsection*{Patches}
32 \index{Patches }
33 \addcontentsline{toc}{subsubsection}{Patches}
34
35 Subject to the copyright assignment described below, your patches should be
36 sent in {\bf diff -u} format relative to the current contents of the Source
37 Forge CVS, which is the easiest for me to understand. If you plan on doing
38 significant development work over a period of time, after having your first
39 patch reviewed and approved, you will be eligible for having CVS access so
40 that you can commit your changes directly to the CVS repository. To do so, you
41 will need a userid on Source Forge. 
42
43 \subsubsection*{Copyrights}
44 \index{Copyrights }
45 \addcontentsline{toc}{subsubsection}{Copyrights}
46
47 To avoid future problems concerning changing licensing or copyrights, all code
48 contributions more than a hand full of lines must be in the Public Domain or
49 have the copyright assigned to Kern Sibbald as in the current code. Note,
50 prior to November 2004, the code was copyrighted by Kern Sibbald and John
51 Walker. 
52
53 Your name should be clearly indicated as the author of the code, and you must
54 be extremely careful not to violate any copyrights or use other people's code
55 without acknowledging it. The purpose of this requirement is to avoid future
56 copyright, patent, or intellectual property problems. To understand on
57 possible source of future problems, please examine the difficulties Mozilla is
58 (was?) having finding previous contributors at 
59 \elink{
60 http://www.mozilla.org/MPL/missing.html}
61 {http://www.mozilla.org/MPL/missing.html}. The other important issue is to
62 avoid copyright, patent, or intellectual property violations as are currently
63 (May 2003) being claimed by SCO against IBM. 
64
65 Although the copyright will be held by Kern, each developer is expected to
66 indicate that he wrote and/or modified a particular module (or file) and any
67 other sources. The copyright assignment may seem a bit unusual, but in
68 reality, it is not. Most large projects require this. In fact, the paperwork
69 associated with making contributions to the Free Software Foundation, was for
70 me unsurmountable. 
71
72 If you have any doubts about this, please don't hesitate to ask. Our (John and
73 my) track records with Autodesk are easily available; early
74 programmers/founders/contributors and later employees had substantial shares
75 of the company, and no one founder had a controlling part of the company. Even
76 though Microsoft created many millionaires among early employees, the politics
77 of Autodesk (during our time at the helm) is in stark contrast to Microsoft
78 where the majority of the company is still tightly held among a few. 
79
80 Items not needing a copyright assignment are: most small changes,
81 enhancements, or bug fixes of 5-10 lines of code, and documentation. 
82
83 \subsubsection*{Copyright Assignment}
84 \index{Copyright Assignment }
85 \index{Assignment!Copyright }
86 \addcontentsline{toc}{subsubsection}{Copyright Assignment}
87
88 Since this is not a commercial enterprise, and I prefer to believe in
89 everyone's good faith, developers can assign the copyright by explicitly
90 acknowledging that they do so in their first submission. This is sufficient if
91 the developer is independent, or an employee of a not-for-profit organization
92 or a university. Any developer that wants to contribute and is employed by a
93 company must get a copyright assignment from his employer. This is to avoid
94 misunderstandings between the employee, the company, and the Bacula project. 
95
96 \subsubsection*{Corporate Assignment Statement}
97 \index{Statement!Corporate Assignment }
98 \index{Corporate Assignment Statement }
99 \addcontentsline{toc}{subsubsection}{Corporate Assignment Statement}
100
101 The following statement must be filled out by the employer, signed, and mailed
102 to my address (please ask me for my address and I will email it -- I'd prefer
103 not to include it here). 
104
105 \footnotesize
106 \begin{verbatim}
107 Copyright release and transfer statement.
108    <On company letter head>
109    To: Kern Sibbald
110    Concerning: Copyright release and transfer
111    <Company, Inc> is hereby agrees that <names-of-developers> and
112    other employees of <Company, Inc> are authorized to develop
113    code for and contribute code to the Bacula project for an
114    undetermined period of time.  The copyright as well as all
115    other rights to and interests in such contributed code are
116    hereby transferred to Kern Sibbald.
117    Signed in <City, Country> on <Date>:
118    <Name of Person>, <Position in Company, Inc>
119 This release/transfer statement must be sent to:
120 Kern Sibbald
121 Address-to-be-given
122 \end{verbatim}
123 \normalsize
124
125 \subsubsection*{Developing Bacula}
126 \index{Developing Bacula }
127 \index{Bacula!Developing }
128 \addcontentsline{toc}{subsubsection}{Developing Bacula}
129
130 Typically the simplest way to develop Bacula is to open one xterm window
131 pointing to the source directory you wish to update; a second xterm window at
132 the top source directory level, and a third xterm window at the bacula
133 directory \lt{}top\gt{}/src/bacula. After making source changes in one of the
134 directories, in the top source directory xterm, build the source, and start
135 the daemons by entering: 
136
137 make and 
138
139 ./startit then in the enter: 
140
141 ./console or 
142
143 ./gnome-console to start the Console program. Enter any commands for testing.
144 For example: run kernsverify full. 
145
146 Note, the instructions here to use {\bf ./startit} are different from using a
147 production system where the administrator starts Bacula by entering {\bf
148 ./bacula start}. This difference allows a development version of {\bf Bacula}
149 to be run on a computer at the same time that a production system is running.
150 The {\bf ./startit} strip starts {\bf Bacula} using a different set of
151 configuration files, and thus permits avoiding conflicts with any production
152 system. 
153
154 To make additional source changes, exit from the Console program, and in the
155 top source directory, stop the daemons by entering: 
156
157 ./stopit then repeat the process. 
158
159 \subsubsection*{Debugging}
160 \index{Debugging }
161 \addcontentsline{toc}{subsubsection}{Debugging}
162
163 Probably the first thing to do is to turn on debug output. 
164
165 A good place to start is with a debug level of 20 as in {\bf ./startit -d20}.
166 The startit command starts all the daemons with the same debug level.
167 Alternatively, you can start the appropriate daemon with the debug level you
168 want. If you really need more info, a debug level of 60 is not bad, and for
169 just about everything a level of 200. 
170
171 \subsubsection*{Using a Debugger}
172 \index{Using a Debugger }
173 \index{Debugger!Using a }
174 \addcontentsline{toc}{subsubsection}{Using a Debugger}
175
176 If you have a serious problem such as a segmentation fault, it can usually be
177 found quickly using a good multiple thread debugger such as {\bf gdb}. For
178 example, suppose you get a segmentation violation in {\bf bacula-dir}. You
179 might use the following to find the problem: 
180
181 \lt{}start the Storage and File daemons\gt{}
182 cd dird
183 gdb ./bacula-dir
184 run -f -s -c ./dird.conf
185 \lt{}it dies with a segmentation fault\gt{}
186 where
187 The {\bf -f} option is specified on the {\bf run} command to inhibit {\bf
188 dird} from going into the background. You may also want to add the {\bf -s}
189 option to the run command to disable signals which can potentially interfere
190 with the debugging. 
191
192 As an alternative to using the debugger, each {\bf Bacula} daemon has a built
193 in back trace feature when a serious error is encountered. It calls the
194 debugger on itself, produces a back trace, and emails the report to the
195 developer. For more details on this, please see the chapter in the main Bacula
196 manual entitled ``What To Do When Bacula Crashes (Kaboom)''. 
197
198 \subsubsection*{Memory Leaks}
199 \index{Leaks!Memory }
200 \index{Memory Leaks }
201 \addcontentsline{toc}{subsubsection}{Memory Leaks}
202
203 Because Bacula runs routinely and unattended on client and server machines, it
204 may run for a long time. As a consequence, from the very beginning, Bacula
205 uses SmartAlloc to ensure that there are no memory leaks. To make detection of
206 memory leaks effective, all Bacula code that dynamically allocates memory MUST
207 have a way to release it. In general when the memory is no longer needed, it
208 should be immediately released, but in some cases, the memory will be held
209 during the entire time that Bacula is executing. In that case, there MUST be a
210 routine that can be called at termination time that releases the memory. In
211 this way, we will be able to detect memory leaks. Be sure to immediately
212 correct any and all memory leaks that are printed at the termination of the
213 daemons. 
214
215 \subsubsection*{Special Files}
216 \index{Files!Special }
217 \index{Special Files }
218 \addcontentsline{toc}{subsubsection}{Special Files}
219
220 Kern uses files named 1, 2, ... 9 with any extension as scratch files. Thus
221 any files with these names are subject to being rudely deleted at any time. 
222
223 \subsubsection*{When Implementing Incomplete Code}
224 \index{Code!When Implementing Incomplete }
225 \index{When Implementing Incomplete Code }
226 \addcontentsline{toc}{subsubsection}{When Implementing Incomplete Code}
227
228 Please identify all incomplete code with a comment that contains {\bf
229 ***FIXME***}, where there are three asterisks (*) before and after the word
230 FIXME (in capitals) and no intervening spaces. This is important as it allows
231 new programmers to easily recognize where things are partially implemented. 
232
233 \subsubsection*{Bacula Source File Structure}
234 \index{Structure!Bacula Source File }
235 \index{Bacula Source File Structure }
236 \addcontentsline{toc}{subsubsection}{Bacula Source File Structure}
237
238 The distribution generally comes as a tar file of the form {\bf
239 bacula.x.y.z.tar.gz} where x, y, and z are the version, release, and update
240 numbers respectively. 
241
242 Once you detar this file, you will have a directory structure as follows: 
243
244 \footnotesize
245 \begin{verbatim}
246 |
247 |- depkgs
248    |- mtx              (autochanger control program + tape drive info)
249    |- sqlite           (SQLite database program)
250 |- depkgs-win32
251    |- pthreads         (Native win32 pthreads library -- dll)
252    |- zlib             (Native win32 zlib library)
253    |- wx               (wxWidgets source code)
254 |- bacula              (main source directory containing configuration
255    |                    and installation files)
256    |- autoconf         (automatic configuration files, not normally used
257    |                    by users)
258    |- doc              (documentation directory)
259       |- home-page     (Bacula's home page source)
260       |- html-manual   (html document directory)
261       |- techlogs      (Technical development notes);
262    |- intl             (programs used to translate)
263    |- platforms        (OS specific installation files)
264       |- redhat        (Red Hat installation)
265       |- solaris       (Sun installation)
266       |- freebsd       (FreeBSD installation)
267       |- irix          (Irix installation -- not tested)
268       |- unknown       (Default if system not identified)
269    |- po               (translations of source strings)
270    |- src              (source directory; contains global header files)
271       |- cats          (SQL catalog database interface directory)
272       |- console       (bacula user agent directory)
273       |- dird          (Director daemon)
274       |- filed         (Unix File daemon)
275          |- win32      (Win32 files to make bacula-fd be a service)
276       |- findlib       (Unix file find library for File daemon)
277       |- gnome-console (GNOME version of console program)
278       |- lib           (General Bacula library)
279       |- stored        (Storage daemon)
280       |- tconsole      (Tcl/tk console program -- not yet working)
281       |- testprogs     (test programs -- normally only in Kern's tree)
282       |- tools         (Various tool programs)
283       |- win32         (Native Win32 File daemon)
284          |- baculafd   (Visual Studio project file)
285          |- compat     (compatibility interface library)
286          |- filed      (links to src/filed)
287          |- findlib    (links to src/findlib)
288          |- lib        (links to src/lib)
289          |- console    (beginning of native console program)
290          |- wx-console (wxWidget console Win32 specific parts)
291      |- wx-console     (wxWidgets console main source program)
292 |- regress             (Regression scripts)
293    |- bin              (temporary directory to hold Bacula installed binaries)
294    |- build            (temporary directory to hold Bacula source)
295    |- scripts          (scripts and .conf files)
296    |- tests            (test scripts)
297    |- tmp              (temporary directory for temp files)
298 \end{verbatim}
299 \normalsize
300
301 \subsubsection*{Header Files}
302 \index{Header Files }
303 \index{Files!Header }
304 \addcontentsline{toc}{subsubsection}{Header Files}
305
306 Please carefully follow the scheme defined below as it permits in general only
307 two header file includes per C file, and thus vastly simplifies programming.
308 With a large complex project like Bacula, it isn't always easy to ensure that
309 the right headers are invoked in the right order (there are a few kludges to
310 make this happen -- i.e. in a few include files because of the chicken and egg
311 problem, certain references to typedefs had to be replaced with {\bf void} ). 
312
313 Every file should include {\bf bacula.h}. It pulls in just about everything,
314 with very few exceptions. If you have system dependent ifdefing, please do it
315 in {\bf baconfig.h}. The version number and date are kept in {\bf version.h}. 
316
317 Each of the subdirectories (console, cats, dird, filed, findlib, lib, stored,
318 ...) contains a single directory dependent include file generally the name of
319 the directory, which should be included just after the include of {\bf
320 bacula.h}. This file (for example, for the dird directory, it is {\bf dird.h})
321 contains either definitions of things generally needed in this directory, or
322 it includes the appropriate header files. It always includes {\bf protos.h}.
323 See below. 
324
325 Each subdirectory contains a header file named {\bf protos.h}, which contains
326 the prototypes for subroutines exported by files in that directory. {\bf
327 protos.h} is always included by the main directory dependent include file. 
328
329 \subsubsection*{Programming Standards}
330 \index{Standards!Programming }
331 \index{Programming Standards }
332 \addcontentsline{toc}{subsubsection}{Programming Standards}
333
334 For the most part, all code should be written in C unless there is a burning
335 reason to use C++, and then only the simplest C++ constructs will be used.
336 Note, Bacula is slowly evolving to use more and more C++. 
337
338 Code should have some documentation -- not a lot, but enough so that I can
339 understand it. Look at the current code, and you will see that I document more
340 than most, but am definitely not a fanatic. 
341
342 I prefer simple linear code where possible. Gotos are strongly discouraged
343 except for handling an error to either bail out or to retry some code, and
344 such use of gotos can vastly simplify the program. 
345
346 Remember this is a C program that is migrating to a {\bf tiny} subset of C++,
347 so be conservative in your use of C++ features. 
348
349 \subsubsection*{Do Not Use}
350 \index{Use!Do Not }
351 \index{Do Not Use }
352 \addcontentsline{toc}{subsubsection}{Do Not Use}
353
354 \begin{itemize}
355 \item STL -- it is totally incomprehensible. 
356    \end{itemize}
357
358 \subsubsection*{Avoid if Possible}
359 \index{Possible!Avoid if }
360 \index{Avoid if Possible }
361 \addcontentsline{toc}{subsubsection}{Avoid if Possible}
362
363 \begin{itemize}
364 \item Returning a malloc'ed buffer from a subroutine --  someone will forget
365    to release it. 
366 \item Using reference variables -- it allows subroutines to  create side
367    effects. 
368 \item Heap allocation (malloc) unless needed -- it is expensive. 
369 \item Templates -- they can create portability problems. 
370 \item Fancy or tricky C or C++ code, unless you give a  good explanation of
371    why you used it. 
372 \item Too much inheritance -- it can complicate the code,  and make reading it
373    difficult (unless you are in love  with colons) 
374    \end{itemize}
375
376 \subsubsection*{Do Use Whenever Possible}
377 \index{Possible!Do Use Whenever }
378 \index{Do Use Whenever Possible }
379 \addcontentsline{toc}{subsubsection}{Do Use Whenever Possible}
380
381 \begin{itemize}
382 \item Locking and unlocking within a single subroutine.  
383 \item Malloc and free within a single subroutine.  
384 \item Comments and global explanations on what your code or  algorithm does. 
385    \end{itemize}
386
387 \subsubsection*{Indenting Standards}
388 \index{Standards!Indenting }
389 \index{Indenting Standards }
390 \addcontentsline{toc}{subsubsection}{Indenting Standards}
391
392 I cannot stand code indented 8 columns at a time. This makes the code
393 unreadable. Even 4 at a time uses a lot of space, so I have adopted indenting
394 3 spaces at every level. Note, indention is the visual appearance of the
395 source on the page, while tabbing is replacing a series of up to 8 spaces from
396 a tab character. 
397
398 The closest set of parameters for the Linux {\bf indent} program that will
399 produce reasonably indented code are: 
400
401 \footnotesize
402 \begin{verbatim}
403 -nbad -bap -bbo -nbc -br -brs -c36 -cd36 -ncdb -ce -ci3 -cli0
404 -cp36 -d0 -di1 -ndj -nfc1 -nfca -hnl -i3 -ip0 -l85 -lp -npcs
405 -nprs -npsl -saf -sai -saw -nsob -nss -nbc -ncs -nbfda
406 \end{verbatim}
407 \normalsize
408
409 You can put the above in your .indent.pro file, and then just invoke indent on
410 your file. However, be warned. This does not produce perfect indenting, and it
411 will mess up C++ class statements pretty badly. 
412
413 Braces are required in all if statements (missing in some very old code). To
414 avoid generating too many lines, the first brace appears on the first line
415 (e.g. of an if), and the closing brace is on a line by itself. E.g. 
416
417 \footnotesize
418 \begin{verbatim}
419    if (abc) {
420       some_code;
421    }
422 \end{verbatim}
423 \normalsize
424
425 Just follow the convention in the code. Originally I indented case clauses
426 under a switch(), but now I prefer non-indented cases. 
427
428 \footnotesize
429 \begin{verbatim}
430    switch (code) {
431    case 'A':
432       do something
433       break;
434    case 'B':
435       again();
436       break;
437    default:
438       break;
439    }
440 \end{verbatim}
441 \normalsize
442
443 Avoid using // style comments except for temporary code or turning off debug
444 code. Standard C comments are preferred (this also keeps the code closer to
445 C). 
446
447 Attempt to keep all lines less than 85 characters long so that the whole line
448 of code is readable at one time. This is not a rigid requirement. 
449
450 Always put a brief description at the top of any new file created describing
451 what it does and including your name and the date it was first written. Please
452 don't forget any Copyrights and acknowledgments if it isn't 100\% your code.
453 Also, include the Bacula copyright notice that is in {\bf src/c}. 
454
455 In general you should have two includes at the top of the an include for the
456 particular directory the code is in, for includes are needed, but this should
457 be rare. 
458
459 In general (except for self-contained packages), prototypes should all be put
460 in {\bf protos.h} in each directory. 
461
462 Always put space around assignment and comparison operators. 
463
464 \footnotesize
465 \begin{verbatim}
466    a = 1;
467    if (b >= 2) {
468      cleanup();
469    }
470 \end{verbatim}
471 \normalsize
472
473 but your can compress things in a {\bf for} statement: 
474
475 \footnotesize
476 \begin{verbatim}
477    for (i=0; i < del.num_ids; i++) {
478     ...
479 \end{verbatim}
480 \normalsize
481
482 Don't overuse the inline if (?:). A full {\bf if} is preferred, except in a
483 print statement, e.g.: 
484
485 \footnotesize
486 \begin{verbatim}
487    if (ua->verbose \&& del.num_del != 0) {
488       bsendmsg(ua, _("Pruned %d %s on Volume %s from catalog.\n"), del.num_del,
489          del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName);
490    }
491 \end{verbatim}
492 \normalsize
493
494 Leave a certain amount of debug code (Dmsg) in code you submit, so that future
495 problems can be identified. This is particularly true for complicated code
496 likely to break. However, try to keep the debug code to a minimum to avoid
497 bloating the program and above all to keep the code readable. 
498
499 Please keep the same style in all new code you develop. If you include code
500 previously written, you have the option of leaving it with the old indenting
501 or re-indenting it. If the old code is indented with 8 spaces, then please
502 re-indent it to Bacula standards. 
503
504 If you are using {\bf vim}, simply set your tabstop to 8 and your shiftwidth
505 to 3. 
506
507 \subsubsection*{Tabbing}
508 \index{Tabbing }
509 \addcontentsline{toc}{subsubsection}{Tabbing}
510
511 Tabbing (inserting the tab character in place of spaces) is as normal on all
512 Unix systems -- a tab is converted space up to the next column multiple of 8.
513 My editor converts strings of spaces to tabs automatically -- this results in
514 significant compression of the files. Thus, you can remove tabs by replacing
515 them with spaces if you wish. Please don't confuse tabbing (use of tab
516 characters) with indenting (visual alignment of the code). 
517
518 \subsubsection*{Don'ts}
519 \index{Don'ts }
520 \addcontentsline{toc}{subsubsection}{Don'ts}
521
522 Please don't use: 
523
524 \footnotesize
525 \begin{verbatim}
526 strcpy()
527 strcat()
528 strncpy()
529 strncat();
530 sprintf()
531 snprintf()
532 \end{verbatim}
533 \normalsize
534
535 They are system dependent and un-safe. These should be replaced by the Bacula
536 safe equivalents: 
537
538 \footnotesize
539 \begin{verbatim}
540 char *bstrncpy(char *dest, char *source, int dest_size);
541 char *bstrncat(char *dest, char *source, int dest_size);
542 int bsnprintf(char *buf, int32_t buf_len, const char *fmt, ...);
543 int bvsnprintf(char *str, int32_t size, const char  *format, va_list ap);
544 \end{verbatim}
545 \normalsize
546
547 See src/lib/bsys.c for more details on these routines. 
548
549 Don't use the {\bf \%lld} or the {\bf \%q} printf format editing types to edit
550 64 bit integers -- they are not portable. Instead, use {\bf \%s} with {\bf
551 edit\_uint64()}. For example: 
552
553 \footnotesize
554 \begin{verbatim}
555    char buf[100];
556    uint64_t num = something;
557    char ed1[50];
558    bsnprintf(buf, sizeof(buf), "Num=%s\n", edit_uint64(num, ed1));
559 \end{verbatim}
560 \normalsize
561
562 The edit buffer {\bf ed1} must be at least 27 bytes long to avoid overflow.
563 See src/lib/edit.c for more details. If you look at the code, don't start
564 screaming that I use {\bf lld}. I actually use subtle trick taught to me by
565 John Walker. The {\bf lld} that appears in the editing routine is actually
566 {\bf \#define} to a what is needed on your OS (usually ``lld'' or ``q'') and
567 is defined in autoconf/configure.in for each OS. C string concatenation causes
568 the appropriate string to be concatenated to the ``\%''. 
569
570 Also please don't use the STL or Templates or any complicated C++ code. 
571
572 \subsubsection*{Message Classes}
573 \index{Classes!Message }
574 \index{Message Classes }
575 \addcontentsline{toc}{subsubsection}{Message Classes}
576
577 Currently, there are four classes of messages: Debug, Error, Job, and Memory. 
578
579 \subsubsection*{Debug Messages}
580 \index{Messages!Debug }
581 \index{Debug Messages }
582 \addcontentsline{toc}{subsubsection}{Debug Messages}
583
584 Debug messages are designed to be turned on at a specified debug level and are
585 always sent to STDOUT. There are designed to only be used in the development
586 debug process. They are coded as: 
587
588 DmsgN(level, message, arg1, ...) where the N is a number indicating how many
589 arguments are to be substituted into the message (i.e. it is a count of the
590 number arguments you have in your message -- generally the number of percent
591 signs (\%)). {\bf level} is the debug level at which you wish the message to
592 be printed. message is the debug message to be printed, and arg1, ... are the
593 arguments to be substituted. Since not all compilers support \#defines with
594 varargs, you must explicitly specify how many arguments you have. 
595
596 When the debug message is printed, it will automatically be prefixed by the
597 name of the daemon which is running, the filename where the Dmsg is, and the
598 line number within the file. 
599
600 Some actual examples are: 
601
602 Dmsg2(20, ``MD5len=\%d MD5=\%s\textbackslash{}n'', strlen(buf), buf); 
603
604 Dmsg1(9, ``Created client \%s record\textbackslash{}n'', client->hdr.name); 
605
606 \subsubsection*{Error Messages}
607 \index{Messages!Error }
608 \index{Error Messages }
609 \addcontentsline{toc}{subsubsection}{Error Messages}
610
611 Error messages are messages that are related to the daemon as a whole rather
612 than a particular job. For example, an out of memory condition my generate an
613 error message. They are coded as: 
614
615 EmsgN(error-code, level, message, arg1, ...) As with debug messages, you must
616 explicitly code the of arguments to be substituted in the message. error-code
617 indicates the severity or class of error, and it may be one of the following: 
618
619 \addcontentsline{lot}{table}{Message Error Code Classes}
620 \begin{longtable}{lp{3in}}
621 {{\bf M\_ABORT}  } & {Causes the daemon to immediately abort. This should be
622 used only  in extreme cases. It attempts to produce a  traceback.  } \\
623 {{\bf M\_ERROR\_TERM}  } & {Causes the daemon to immediately terminate. This
624 should be used only  in extreme cases. It does not produce a  traceback.  } \\
625 {{\bf M\_FATAL}  } & {Causes the daemon to terminate the current job, but the
626 daemon keeps running  } \\
627 {{\bf M\_ERROR}  } & {Reports the error. The daemon and the job continue
628 running  } \\
629 {{\bf M\_WARNING}  } & {Reports an warning message. The daemon and the job
630 continue running  } \\
631 {{\bf M\_INFO}  } & {Reports an informational message. }
632
633 \end{longtable}
634
635 There are other error message classes, but they are in a state of being
636 redesigned or deprecated, so please do not use them. Some actual examples are:
637
638
639 Emsg1(M\_ABORT, 0, ``Cannot create message thread: \%s\textbackslash{}n'',
640 strerror(status)); 
641
642 Emsg3(M\_WARNING, 0, ``Connect to File daemon \%s at \%s:\%d failed. Retrying
643 ...\textbackslash{}n'',  client-\gt{}hdr.name, client-\gt{}address,
644 client-\gt{}port); 
645
646 Emsg3(M\_FATAL, 0, ``bdird\lt{}filed: bad response from Filed to \%s command:
647 \%d \%s\textbackslash{}n'',  cmd, n, strerror(errno)); 
648
649 \subsubsection*{Job Messages}
650 \index{Job Messages }
651 \index{Messages!Job }
652 \addcontentsline{toc}{subsubsection}{Job Messages}
653
654 Job messages are messages that pertain to a particular job such as a file that
655 could not be saved, or the number of files and bytes that were saved. 
656
657 \subsubsection*{Memory Messages}
658 \index{Messages!Memory }
659 \index{Memory Messages }
660 \addcontentsline{toc}{subsubsection}{Memory Messages}
661
662 Memory messages are messages that are edited into a memory buffer. Generally
663 they are used in low level routines such as the low level device file dev.c in
664 the Storage daemon or in the low level Catalog routines. These routines do not
665 generally have access to the Job Control Record and so they return error
666 messages reformatted in a memory buffer. Mmsg() is the way to do this.