/[baselayout]/trunk/src/libeinfo.c
Gentoo

Diff of /trunk/src/libeinfo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2549 Revision 2550
90 if (! var) 90 if (! var)
91 return (false); 91 return (false);
92 92
93 v = getenv (var); 93 v = getenv (var);
94 if (! v) 94 if (! v)
95 return (val == NULL ? true : false); 95 return (val ? false : true);
96 96
97 return (strcasecmp (v, val) == 0 ? true : false); 97 return (strcasecmp (v, val) ? false : true);
98} 98}
99 99
100bool colour_terminal (void) 100bool colour_terminal (void)
101{ 101{
102 static int in_colour = -1; 102 static int in_colour = -1;
162 162
163 fprintf (fp, "%s %d ", cmd, retval); 163 fprintf (fp, "%s %d ", cmd, retval);
164 164
165 if (fmt) 165 if (fmt)
166 { 166 {
167 va_list apc;
168 va_copy (apc, ap);
167 l = vsnprintf (buffer, sizeof (buffer), fmt, ap); 169 l = vsnprintf (buffer, sizeof (buffer), fmt, apc);
168 fprintf (fp, "%d %s\n", l, buffer); 170 fprintf (fp, "%d %s\n", l, buffer);
171 va_end (apc);
169 } 172 }
170 else 173 else
171 fprintf (fp, "0\n"); 174 fprintf (fp, "0\n");
172 175
173 fclose (fp); 176 fclose (fp);
349} 352}
350 353
351static void elog (int level, const char *fmt, va_list ap) 354static void elog (int level, const char *fmt, va_list ap)
352{ 355{
353 char *e = getenv ("RC_ELOG"); 356 char *e = getenv ("RC_ELOG");
357 va_list apc;
354 358
355 if (e) 359 if (fmt && e)
356 { 360 {
357 closelog (); 361 closelog ();
358 openlog (e, LOG_PID, LOG_DAEMON); 362 openlog (e, LOG_PID, LOG_DAEMON);
363 va_copy (apc, ap);
359 vsyslog (level, fmt, ap); 364 vsyslog (level, fmt, apc);
365 va_end (apc);
366 closelog ();
360 } 367 }
361} 368}
362static int _eindent (FILE *stream) 369static int _eindent (FILE *stream)
363{ 370{
364 char *env = getenv ("RC_EINDENT"); 371 char *env = getenv ("RC_EINDENT");
388 if (colour_terminal ()) \ 395 if (colour_terminal ()) \
389 fprintf (_file, " " _colour "*" EINFO_NORMAL " "); \ 396 fprintf (_file, " " _colour "*" EINFO_NORMAL " "); \
390 else \ 397 else \
391 fprintf (_file, " * "); \ 398 fprintf (_file, " * "); \
392 retval += _eindent (_file); \ 399 retval += _eindent (_file); \
400 { \
401 va_list _ap; \
402 va_copy (_ap, ap); \
393 retval += vfprintf (_file, fmt, ap) + 3; \ 403 retval += vfprintf (_file, fmt, _ap) + 3; \
404 va_end (_ap); \
405 } \
394 if (colour_terminal ()) \ 406 if (colour_terminal ()) \
395 fprintf (_file, "\033[K"); 407 fprintf (_file, "\033[K");
396 408
397static int _veinfon (const char *fmt, va_list ap) 409static int _veinfon (const char *fmt, va_list ap)
398{ 410{
624 636
625static int _do_eend (const char *cmd, int retval, const char *fmt, va_list ap) 637static int _do_eend (const char *cmd, int retval, const char *fmt, va_list ap)
626{ 638{
627 int col = 0; 639 int col = 0;
628 FILE *fp; 640 FILE *fp;
641 va_list apc;
642 int eb;
629 643
644 if (fmt)
645 {
646 va_copy (apc, ap);
630 if (ebuffer (cmd, retval, fmt, ap)) 647 eb = ebuffer (cmd, retval, fmt, apc);
648 va_end (apc);
649 if (eb)
631 return (retval); 650 return (retval);
651 }
632 652
633 if (fmt && retval != 0) 653 if (fmt && retval != 0)
634 { 654 {
655 va_copy (apc, ap);
635 if (strcmp (cmd, "ewend") == 0) 656 if (strcmp (cmd, "ewend") == 0)
636 { 657 {
637 col = _vewarnn (fmt, ap); 658 col = _vewarnn (fmt, apc);
638 fp = stdout; 659 fp = stdout;
639 } 660 }
640 else 661 else
641 { 662 {
642 col = _veerrorn (fmt, ap); 663 col = _veerrorn (fmt, apc);
643 fp = stderr; 664 fp = stderr;
644 } 665 }
666 va_end (apc);
645 if (colour_terminal ()) 667 if (colour_terminal ())
646 fprintf (fp, "\n"); 668 fprintf (fp, "\n");
647 } 669 }
648 670
649 _eend (col, retval == 0 ? einfo_good : einfo_bad, retval == 0 ? OK : NOT_OK); 671 _eend (col, retval == 0 ? einfo_good : einfo_bad, retval == 0 ? OK : NOT_OK);

Legend:
Removed from v.2549  
changed lines
  Added in v.2550

  ViewVC Help
Powered by ViewVC 1.1.20