This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fprintf control from Environment variable.


On Mon, Oct 8, 2012 at 10:22 PM, naveen yadav <yad.naveen@gmail.com> wrote:
>
> I want to control the print message being sent to stdout and stderr
> using printf(), vprintf() and fprintf() function call for better
> performance.
>
> For this I have added following code in vfprintf() function
>   static int Verbose = 0;
>   if(stream == stdout || stream == stderr)
>   {
>       if (Verbose == 0)
>      Verbose = getenv ("PRINT") ? 1 : 2;
>       if (Verbose == 1)
>      return 0;
>   }

That seems really unwise.  Do this kind of thing in your application,
not in your C library.  If for some reason you truly must do it in
your C library, do it at level of write, not at the level of printf.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]