trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: January 2012

Re: [trinity-devel] %s, %h variables, etc.

From: /dev/ammo42 <mickeytintincolle@...>
Date: Sat, 21 Jan 2012 20:11:17 +0100
On Sat, 21 Jan 2012 10:55:19 -0800 (PST)
Darrell Anderson <humanreadable@...> wrote:

> > Subject: Re: [trinity-devel] %s, %h variables, etc.
> > > Where are these variables
> > defined?
> > >
> > > I think %h is host name.
> > >
> > > There must be list somewhere deep within TDE.
> 
> > Context please?  I have no idea which variables you
> > are talking about. :-)
> 
> Okay. Let me back up. I think this is two questions.
> 
> Calvin, yes, this is a stdlib variable.
> 
> First, in KDM kdmrc is a list of variables:
> 
> %d -> current display
> %h -> host name, possibly with domain name
> %n -> node name, most probably the host name without domain name
> %s -> the operating system
> %r -> the operating system's version
> %m -> the machine (hardware) type
> 
> I was partially trying to remember that list. That list should not be
> confused with the specific usage I want to understand, which is found
> in tdebase/kdm/backend/error.c:102:
> 
> sprintf( buf, "/var/log/%s.log", prog );
> 
> When I look in /var/log, I know that "%s" is translated to "kdm."
> 
> As I am learning C/C++, I know that %s in that line is stdlib for
> string, and "prog" is the data to be passed to sprintf as a string.
> What is the value of "prog"?
> 
> I see that dm.h is part of the preprocessor includes. In dm.h, prog
> is defined as an extern char variable. (Although I don't know what
> the asterisk means. :) )
> 
> I still don't where prog is assigned the value of "kdm."
In dm.c, line 159. This variable is exported in dm.h, and its value is
computed at run-time, for Linux systems (the code is in a "#ifdef
__linux__"), as the file pointed by the /proc/self/exe symlink (which
always points to the binary of the executable). More precisely,
progpath is the full path and prog is the file name of the binary.
If kdm was renamed to tdm, it would automagically rename kdm.log to
tdm.log.
> 
> I want to submit a patch for bug report 618, which I created. A
> simple bug report like this is a good way to help me learn a little
> more about C++. When I better understand the context of %s in
> error.c, that is, where prog is assigned the value of kdm, I can
> submit a patch.
> 
> Darrell
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> trinity-devel-unsubscribe@... For additional
> commands, e-mail: trinity-devel-help@... Read
> list messsages on the Web archive:
> http://trinity-devel.pearsoncomputing.net/ Please remember not to
> top-post:
> http://trinity.pearsoncomputing.net/mailing_lists/#top-posting
>