getpid() -> sys_getpid()
[kai/samba.git] / source3 / lib / debug.c
1 /*
2    Unix SMB/CIFS implementation.
3    Samba utility functions
4    Copyright (C) Andrew Tridgell 1992-1998
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22
23 /* -------------------------------------------------------------------------- **
24  * Defines...
25  *
26  *  FORMAT_BUFR_MAX - Index of the last byte of the format buffer;
27  *                    format_bufr[FORMAT_BUFR_MAX] should always be reserved
28  *                    for a terminating null byte.
29  */
30
31 #define FORMAT_BUFR_MAX ( sizeof( format_bufr ) - 1 )
32
33 /* -------------------------------------------------------------------------- **
34  * This module implements Samba's debugging utility.
35  *
36  * The syntax of a debugging log file is represented as:
37  *
38  *  <debugfile> :== { <debugmsg> }
39  *
40  *  <debugmsg>  :== <debughdr> '\n' <debugtext>
41  *
42  *  <debughdr>  :== '[' TIME ',' LEVEL ']' [ [FILENAME ':'] [FUNCTION '()'] ]
43  *
44  *  <debugtext> :== { <debugline> }
45  *
46  *  <debugline> :== TEXT '\n'
47  *
48  * TEXT     is a string of characters excluding the newline character.
49  * LEVEL    is the DEBUG level of the message (an integer in the range 0..10).
50  * TIME     is a timestamp.
51  * FILENAME is the name of the file from which the debug message was generated.
52  * FUNCTION is the function from which the debug message was generated.
53  *
54  * Basically, what that all means is:
55  *
56  * - A debugging log file is made up of debug messages.
57  *
58  * - Each debug message is made up of a header and text.  The header is
59  *   separated from the text by a newline.
60  *
61  * - The header begins with the timestamp and debug level of the message
62  *   enclosed in brackets.  The filename and function from which the
63  *   message was generated may follow.  The filename is terminated by a
64  *   colon, and the function name is terminated by parenthesis.
65  *
66  * - The message text is made up of zero or more lines, each terminated by
67  *   a newline.
68  */
69
70 /* -------------------------------------------------------------------------- **
71  * External variables.
72  *
73  *  dbf           - Global debug file handle.
74  *  debugf        - Debug file name.
75  *  append_log    - If True, then the output file will be opened in append
76  *                  mode.
77  *  DEBUGLEVEL    - System-wide debug message limit.  Messages with message-
78  *                  levels higher than DEBUGLEVEL will not be processed.
79  */
80
81 XFILE   *dbf        = NULL;
82 pstring debugf     = "";
83 BOOL    append_log = False;
84
85 int     DEBUGLEVEL_CLASS[DBGC_LAST];
86 BOOL    DEBUGLEVEL_CLASS_ISSET[DBGC_LAST];
87 int     DEBUGLEVEL = DEBUGLEVEL_CLASS;
88 BOOL    AllowDebugChange = True;
89
90
91 /* -------------------------------------------------------------------------- **
92  * Internal variables.
93  *
94  *  stdout_logging  - Default False, if set to True then dbf will be set to
95  *                    stdout and debug output will go to dbf only, and not
96  *                    to syslog.  Set in setup_logging() and read in Debug1().
97  *
98  *  debug_count     - Number of debug messages that have been output.
99  *                    Used to check log size.
100  *
101  *  syslog_level    - Internal copy of the message debug level.  Written by
102  *                    dbghdr() and read by Debug1().
103  *
104  *  format_bufr     - Used to format debug messages.  The dbgtext() function
105  *                    prints debug messages to a string, and then passes the
106  *                    string to format_debug_text(), which uses format_bufr
107  *                    to build the formatted output.
108  *
109  *  format_pos      - Marks the first free byte of the format_bufr.
110  * 
111  *
112  *  log_overflow    - When this variable is True, never attempt to check the
113  *                    size of the log. This is a hack, so that we can write
114  *                    a message using DEBUG, from open_logs() when we
115  *                    are unable to open a new log file for some reason.
116  */
117
118 static BOOL    stdout_logging = False;
119 static int     debug_count    = 0;
120 #ifdef WITH_SYSLOG
121 static int     syslog_level   = 0;
122 #endif
123 static pstring format_bufr    = { '\0' };
124 static size_t     format_pos     = 0;
125 static BOOL    log_overflow   = False;
126
127 /*
128  * Define all the debug class selection names here. Names *MUST NOT* contain 
129  * white space. There must be one name for each DBGC_<class name>, and they 
130  * must be in the table in the order of DBGC_<class name>.. 
131  */
132 char *classname_table[] = {
133         "all",               /* DBGC_ALL; index refs traditional DEBUGLEVEL */
134         "tdb",               /* DBGC_TDB          */
135         "printdrivers",      /* DBGC_PRINTDRIVERS */
136         "lanman",            /* DBGC_LANMAN       */
137         "smb",               /* DBGC_SMB          */
138         "rpc",               /* DBGC_RPC          */
139         "rpc_hdr",           /* DBGC_RPC_HDR      */
140         "bdc",               /* DBGC_BDC          */
141 };
142
143
144 /* -------------------------------------------------------------------------- **
145  * Functions...
146  */
147
148 /****************************************************************************
149 utility access to debug class names's
150 ****************************************************************************/
151 char* debug_classname_from_index(int ndx)
152 {
153         return classname_table[ndx];
154 }
155
156 /****************************************************************************
157 utility to translate names to debug class index's
158 ****************************************************************************/
159 int debug_lookup_classname(char* classname)
160 {
161         int i;
162
163         if (!classname) return -1;
164
165         for (i=0; i<DBGC_LAST; i++) {
166                 if (strcmp(classname, classname_table[i])==0)
167                         return i;
168         }
169         return -1;
170 }
171
172 /****************************************************************************
173 parse the debug levels from smbcontrol. Example debug level parameter:
174   printdrivers:7
175 ****************************************************************************/
176 BOOL debug_parse_params(char **params, int *debuglevel_class,
177                         BOOL *debuglevel_class_isset)
178 {
179         int   i, ndx;
180         char *class_name;
181         char *class_level;
182         
183         /* Set the new debug level array to the current DEBUGLEVEL array */
184         memcpy(debuglevel_class, DEBUGLEVEL_CLASS, sizeof(DEBUGLEVEL_CLASS));
185
186         /* Allow DBGC_ALL to be specified w/o requiring its class name e.g."10"  
187          * v.s. "all:10", this is the traditional way to set DEBUGLEVEL 
188          */
189         if (isdigit((int)params[0][0])) {
190                 debuglevel_class[DBGC_ALL] = atoi(params[0]);
191                 debuglevel_class_isset[DBGC_ALL] = True;
192                 i = 1; /* start processing at the next params */
193         }
194         else
195                 i = 0; /* DBGC_ALL not specified OR class name was included */
196
197         /* Fill in new debug class levels */
198         for (; i < DBGC_LAST && params[i]; i++) {
199                 if ((class_name=strtok(params[i],":")) &&
200                         (class_level=strtok(NULL, "\0")) &&
201             ((ndx = debug_lookup_classname(class_name)) != -1)) {
202                                 debuglevel_class[ndx] = atoi(class_level);
203                                 debuglevel_class_isset[ndx] = True;
204                 } else {
205                         DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i]));
206                         return False;
207                 }
208         }
209
210         return True;
211 }
212
213 /****************************************************************************
214 parse the debug levels from smb.conf. Example debug level string:
215   3 tdb:5 printdrivers:7
216 Note: the 1st param has no "name:" preceeding it.
217 ****************************************************************************/
218 BOOL debug_parse_levels(char *params_str)
219 {
220         int  i;
221         char *params[DBGC_LAST];
222         int  debuglevel_class[DBGC_LAST];       
223         BOOL debuglevel_class_isset[DBGC_LAST];
224
225         if (AllowDebugChange == False)
226                 return True;
227         ZERO_ARRAY(params);
228         ZERO_ARRAY(debuglevel_class);
229         ZERO_ARRAY(debuglevel_class_isset);
230
231         if ((params[0]=strtok(params_str," ,"))) {
232                 for (i=1; i<DBGC_LAST;i++) {
233                         if ((params[i]=strtok(NULL," ,"))==NULL)
234                                 break;
235                 }
236         }
237         else
238                 return False;
239
240         if (debug_parse_params(params, debuglevel_class, 
241                                debuglevel_class_isset)) {
242                 debug_message(0, sys_getpid(), (void*)debuglevel_class, sizeof(debuglevel_class));
243
244                 memcpy(DEBUGLEVEL_CLASS, debuglevel_class, 
245                        sizeof(debuglevel_class));
246
247                 memcpy(DEBUGLEVEL_CLASS_ISSET, debuglevel_class_isset,
248                        sizeof(debuglevel_class_isset));
249
250                 {
251                         int q;
252
253                         for (q = 0; q < DBGC_LAST; q++)
254                                 DEBUG(5, ("%s: %d/%d\n",
255                                           classname_table[q],
256                                           DEBUGLEVEL_CLASS[q],
257                                           DEBUGLEVEL_CLASS_ISSET[q]));
258                 }
259
260                 return True;
261         } else
262                 return False;
263 }
264
265 /****************************************************************************
266 receive a "set debug level" message
267 ****************************************************************************/
268 void debug_message(int msg_type, pid_t src, void *buf, size_t len)
269 {
270         struct debuglevel_message *dm = (struct debuglevel_message *)buf;
271         int i;
272
273         /* Set the new DEBUGLEVEL_CLASS array from the passed message */
274         memcpy(DEBUGLEVEL_CLASS, dm->debuglevel_class, sizeof(dm->debuglevel_class));
275         memcpy(DEBUGLEVEL_CLASS_ISSET, dm->debuglevel_class_isset, sizeof(dm->debuglevel_class_isset));
276
277         DEBUG(3,("INFO: Debug class %s level = %d   (pid %u from pid %u)\n",
278                         classname_table[DBGC_ALL],
279                         DEBUGLEVEL_CLASS[DBGC_ALL], (unsigned int)sys_getpid(), (unsigned int)src));
280
281         for (i=1; i<DBGC_LAST; i++) {
282                 if (DEBUGLEVEL_CLASS[i])
283                          DEBUGADD(3,("INFO: Debug class %s level = %d\n", 
284                                                 classname_table[i], DEBUGLEVEL_CLASS[i]));
285         }
286 }
287
288
289 /****************************************************************************
290 send a "set debug level" message
291 ****************************************************************************/
292 void debug_message_send(pid_t pid, int level)
293 {
294         message_send_pid(pid, MSG_DEBUG, &level, sizeof(int), False);
295 }
296
297
298 /* ************************************************************************** **
299  * get ready for syslog stuff
300  * ************************************************************************** **
301  */
302 void setup_logging(char *pname, BOOL interactive)
303 {
304         message_register(MSG_DEBUG, debug_message);
305
306         /* reset to allow multiple setup calls, going from interactive to
307            non-interactive */
308         stdout_logging = False;
309         dbf = NULL;
310
311         if (interactive) {
312                 stdout_logging = True;
313                 dbf = x_stdout;
314         }
315 #ifdef WITH_SYSLOG
316         else {
317                 char *p = strrchr_m( pname,'/' );
318                 if (p)
319                         pname = p + 1;
320 #ifdef LOG_DAEMON
321                 openlog( pname, LOG_PID, SYSLOG_FACILITY );
322 #else
323                 /* for old systems that have no facility codes. */
324                 openlog( pname, LOG_PID );
325 #endif
326         }
327 #endif
328 } /* setup_logging */
329
330 /* ************************************************************************** **
331  * reopen the log files
332  * note that we now do this unconditionally
333  * We attempt to open the new debug fp before closing the old. This means
334  * if we run out of fd's we just keep using the old fd rather than aborting.
335  * Fix from dgibson@linuxcare.com.
336  * ************************************************************************** **
337  */
338
339 BOOL reopen_logs( void )
340 {
341         pstring fname;
342         mode_t oldumask;
343         XFILE *new_dbf = NULL;
344         BOOL ret = True;
345
346         if (stdout_logging)
347                 return True;
348
349         oldumask = umask( 022 );
350   
351         pstrcpy(fname, debugf );
352
353         if (lp_loaded()) {
354                 char *logfname;
355
356                 logfname = lp_logfile();
357                 if (*logfname)
358                         pstrcpy(fname, logfname);
359         }
360
361         pstrcpy( debugf, fname );
362         if (append_log)
363                 new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644);
364         else
365                 new_dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 );
366
367         if (!new_dbf) {
368                 log_overflow = True;
369                 DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno)));
370                 log_overflow = False;
371                 if (dbf)
372                         x_fflush(dbf);
373                 ret = False;
374         } else {
375                 x_setbuf(new_dbf, NULL);
376                 if (dbf)
377                         (void) x_fclose(dbf);
378                 dbf = new_dbf;
379         }
380
381         /* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De
382          * to fix problem where smbd's that generate less
383          * than 100 messages keep growing the log.
384          */
385         force_check_log_size();
386         (void)umask(oldumask);
387
388         return ret;
389 }
390
391 /* ************************************************************************** **
392  * Force a check of the log size.
393  * ************************************************************************** **
394  */
395 void force_check_log_size( void )
396 {
397   debug_count = 100;
398 }
399
400 /***************************************************************************
401  Check to see if there is any need to check if the logfile has grown too big.
402 **************************************************************************/
403
404 BOOL need_to_check_log_size( void )
405 {
406         int maxlog;
407
408         if( debug_count++ < 100 )
409                 return( False );
410
411         maxlog = lp_max_log_size() * 1024;
412         if( !dbf || maxlog <= 0 ) {
413                 debug_count = 0;
414                 return(False);
415         }
416         return( True );
417 }
418
419 /* ************************************************************************** **
420  * Check to see if the log has grown to be too big.
421  * ************************************************************************** **
422  */
423
424 void check_log_size( void )
425 {
426         int         maxlog;
427         SMB_STRUCT_STAT st;
428
429         /*
430          *  We need to be root to check/change log-file, skip this and let the main
431          *  loop check do a new check as root.
432          */
433
434         if( geteuid() != 0 )
435                 return;
436
437         if(log_overflow || !need_to_check_log_size() )
438                 return;
439
440         maxlog = lp_max_log_size() * 1024;
441
442         if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
443                 (void)reopen_logs();
444                 if( dbf && get_file_size( debugf ) > maxlog ) {
445                         pstring name;
446
447                         slprintf( name, sizeof(name)-1, "%s.old", debugf );
448                         (void)rename( debugf, name );
449       
450                         if (!reopen_logs()) {
451                                 /* We failed to reopen a log - continue using the old name. */
452                                 (void)rename(name, debugf);
453                         }
454                 }
455         }
456
457         /*
458          * Here's where we need to panic if dbf == NULL..
459          */
460
461         if(dbf == NULL) {
462                 /* This code should only be reached in very strange
463                  * circumstances. If we merely fail to open the new log we
464                  * should stick with the old one. ergo this should only be
465                  * reached when opening the logs for the first time: at
466                  * startup or when the log level is increased from zero.
467                  * -dwg 6 June 2000
468                  */
469                 dbf = x_fopen( "/dev/console", O_WRONLY, 0);
470                 if(dbf) {
471                         DEBUG(0,("check_log_size: open of debug file %s failed - using console.\n",
472                                         debugf ));
473                 } else {
474                         /*
475                          * We cannot continue without a debug file handle.
476                          */
477                         abort();
478                 }
479         }
480         debug_count = 0;
481 } /* check_log_size */
482
483 /* ************************************************************************** **
484  * Write an debug message on the debugfile.
485  * This is called by dbghdr() and format_debug_text().
486  * ************************************************************************** **
487  */
488  int Debug1( char *format_str, ... )
489 {
490   va_list ap;  
491   int old_errno = errno;
492
493   if( stdout_logging )
494     {
495     va_start( ap, format_str );
496     if(dbf)
497       (void)x_vfprintf( dbf, format_str, ap );
498     va_end( ap );
499     errno = old_errno;
500     return( 0 );
501     }
502   
503 #ifdef WITH_SYSLOG
504   if( !lp_syslog_only() )
505 #endif
506     {
507     if( !dbf )
508       {
509       mode_t oldumask = umask( 022 );
510
511       if( append_log )
512         dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 );
513       else
514         dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 );
515       (void)umask( oldumask );
516       if( dbf )
517         {
518         x_setbuf( dbf, NULL );
519         }
520       else
521         {
522         errno = old_errno;
523         return(0);
524         }
525       }
526     }
527
528 #ifdef WITH_SYSLOG
529   if( syslog_level < lp_syslog() )
530     {
531     /* map debug levels to syslog() priorities
532      * note that not all DEBUG(0, ...) calls are
533      * necessarily errors
534      */
535     static int priority_map[] = { 
536       LOG_ERR,     /* 0 */
537       LOG_WARNING, /* 1 */
538       LOG_NOTICE,  /* 2 */
539       LOG_INFO,    /* 3 */
540       };
541     int     priority;
542     pstring msgbuf;
543
544     if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) )
545      || syslog_level < 0)
546       priority = LOG_DEBUG;
547     else
548       priority = priority_map[syslog_level];
549       
550     va_start( ap, format_str );
551     vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
552     va_end( ap );
553       
554     msgbuf[255] = '\0';
555     syslog( priority, "%s", msgbuf );
556     }
557 #endif
558   
559   check_log_size();
560
561 #ifdef WITH_SYSLOG
562   if( !lp_syslog_only() )
563 #endif
564     {
565     va_start( ap, format_str );
566     if(dbf)
567       (void)x_vfprintf( dbf, format_str, ap );
568     va_end( ap );
569     if(dbf)
570       (void)x_fflush( dbf );
571     }
572
573   errno = old_errno;
574
575   return( 0 );
576   } /* Debug1 */
577
578
579 /* ************************************************************************** **
580  * Print the buffer content via Debug1(), then reset the buffer.
581  *
582  *  Input:  none
583  *  Output: none
584  *
585  * ************************************************************************** **
586  */
587 static void bufr_print( void )
588   {
589   format_bufr[format_pos] = '\0';
590   (void)Debug1( "%s", format_bufr );
591   format_pos = 0;
592   } /* bufr_print */
593
594 /* ************************************************************************** **
595  * Format the debug message text.
596  *
597  *  Input:  msg - Text to be added to the "current" debug message text.
598  *
599  *  Output: none.
600  *
601  *  Notes:  The purpose of this is two-fold.  First, each call to syslog()
602  *          (used by Debug1(), see above) generates a new line of syslog
603  *          output.  This is fixed by storing the partial lines until the
604  *          newline character is encountered.  Second, printing the debug
605  *          message lines when a newline is encountered allows us to add
606  *          spaces, thus indenting the body of the message and making it
607  *          more readable.
608  *
609  * ************************************************************************** **
610  */
611 static void format_debug_text( char *msg )
612   {
613   size_t i;
614   BOOL timestamp = (!stdout_logging && (lp_timestamp_logs() || 
615                                         !(lp_loaded())));
616
617   for( i = 0; msg[i]; i++ )
618     {
619     /* Indent two spaces at each new line. */
620     if(timestamp && 0 == format_pos)
621       {
622       format_bufr[0] = format_bufr[1] = ' ';
623       format_pos = 2;
624       }
625
626     /* If there's room, copy the character to the format buffer. */
627     if( format_pos < FORMAT_BUFR_MAX )
628       format_bufr[format_pos++] = msg[i];
629
630     /* If a newline is encountered, print & restart. */
631     if( '\n' == msg[i] )
632       bufr_print();
633
634     /* If the buffer is full dump it out, reset it, and put out a line
635      * continuation indicator.
636      */
637     if( format_pos >= FORMAT_BUFR_MAX )
638       {
639       bufr_print();
640       (void)Debug1( " +>\n" );
641       }
642     }
643
644   /* Just to be safe... */
645   format_bufr[format_pos] = '\0';
646   } /* format_debug_text */
647
648 /* ************************************************************************** **
649  * Flush debug output, including the format buffer content.
650  *
651  *  Input:  none
652  *  Output: none
653  *
654  * ************************************************************************** **
655  */
656 void dbgflush( void )
657   {
658   bufr_print();
659   if(dbf)
660     (void)x_fflush( dbf );
661   } /* dbgflush */
662
663 /* ************************************************************************** **
664  * Print a Debug Header.
665  *
666  *  Input:  level - Debug level of the message (not the system-wide debug
667  *                  level. )
668  *          file  - Pointer to a string containing the name of the file
669  *                  from which this function was called, or an empty string
670  *                  if the __FILE__ macro is not implemented.
671  *          func  - Pointer to a string containing the name of the function
672  *                  from which this function was called, or an empty string
673  *                  if the __FUNCTION__ macro is not implemented.
674  *          line  - line number of the call to dbghdr, assuming __LINE__
675  *                  works.
676  *
677  *  Output: Always True.  This makes it easy to fudge a call to dbghdr()
678  *          in a macro, since the function can be called as part of a test.
679  *          Eg: ( (level <= DEBUGLEVEL) && (dbghdr(level,"",line)) )
680  *
681  *  Notes:  This function takes care of setting syslog_level.
682  *
683  * ************************************************************************** **
684  */
685
686 BOOL dbghdr( int level, char *file, char *func, int line )
687 {
688   /* Ensure we don't lose any real errno value. */
689   int old_errno = errno;
690
691   if( format_pos ) {
692     /* This is a fudge.  If there is stuff sitting in the format_bufr, then
693      * the *right* thing to do is to call
694      *   format_debug_text( "\n" );
695      * to write the remainder, and then proceed with the new header.
696      * Unfortunately, there are several places in the code at which
697      * the DEBUG() macro is used to build partial lines.  That in mind,
698      * we'll work under the assumption that an incomplete line indicates
699      * that a new header is *not* desired.
700      */
701     return( True );
702   }
703
704 #ifdef WITH_SYSLOG
705   /* Set syslog_level. */
706   syslog_level = level;
707 #endif
708
709   /* Don't print a header if we're logging to stdout. */
710   if( stdout_logging )
711     return( True );
712
713   /* Print the header if timestamps are turned on.  If parameters are
714    * not yet loaded, then default to timestamps on.
715    */
716   if( lp_timestamp_logs() || !(lp_loaded()) ) {
717     char header_str[200];
718
719         header_str[0] = '\0';
720
721         if( lp_debug_pid())
722           slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)sys_getpid());
723
724         if( lp_debug_uid()) {
725       size_t hs_len = strlen(header_str);
726           slprintf(header_str + hs_len,
727                sizeof(header_str) - 1 - hs_len,
728                            ", effective(%u, %u), real(%u, %u)",
729                (unsigned int)geteuid(), (unsigned int)getegid(),
730                            (unsigned int)getuid(), (unsigned int)getgid()); 
731         }
732   
733     /* Print it all out at once to prevent split syslog output. */
734     (void)Debug1( "[%s, %d%s] %s:%s(%d)\n",
735                   timestring(lp_debug_hires_timestamp()), level,
736                                   header_str, file, func, line );
737   }
738
739   errno = old_errno;
740   return( True );
741 }
742
743 /* ************************************************************************** **
744  * Add text to the body of the "current" debug message via the format buffer.
745  *
746  *  Input:  format_str  - Format string, as used in printf(), et. al.
747  *          ...         - Variable argument list.
748  *
749  *  ..or..  va_alist    - Old style variable parameter list starting point.
750  *
751  *  Output: Always True.  See dbghdr() for more info, though this is not
752  *          likely to be used in the same way.
753  *
754  * ************************************************************************** **
755  */
756  BOOL dbgtext( char *format_str, ... )
757   {
758   va_list ap;
759   pstring msgbuf;
760
761   va_start( ap, format_str ); 
762   vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
763   va_end( ap );
764
765   format_debug_text( msgbuf );
766
767   return( True );
768   } /* dbgtext */
769
770
771 /* ************************************************************************** */