Go Back   openSUSE Forums > Archives > SF Archives > ARCHIVES - Programming & Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


ARCHIVES - Programming & Scripting A place to discuss website design, programming, shell scripts, etc

 
Page 1 of 2 1 2
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 26-Mar-2007, 16:47
harryc
Guest
 
Posts: n/a
Default

This is a question that I have been wondering about since I first started using Linux, maybe 6 years ago. In KDE or GNOME control panels, preferences etc, I often see apps coded to start like this;

firefox %s

or

thunderbird %u

What do those command extensions do? In other words what specifically does %s do and where can I find a list of all such extra control characters/extensions(if that's what you call them)
  #2 (permalink)  
Old 28-Mar-2007, 15:39
bobbyn
Guest
 
Posts: n/a
Default

Hi Harryc,

No aswer on your otherwise interresting query. I've tried to find some logic in the parameters passed between various programs, but cannot find any either. Tried to find something on the net, but no luck. Thumbed through my (old and new) unix/Linux books, but nothing there either. There are some references to % type varable substitutions in AWK and such, but nothing I can point to as a standard. In programs like Firefox, Thunderbird, the parameters passed do not rely on a standard character such as a % sign. The parameters passed depend an a so-called calling convention, that is defined as a standard when a compiler such as C, C++ is called.

For C C++ in Linux, tnat is :

Arguments are pushed on the stack in reverse order.
The caller pops arguments after return.
Primitive data types, except floating point values, are returned in EAX or EAX:EDX depending on the size.
float and double are returned in fp0, i.e. the first floating point register.
All structures and classes are returned in memory regardless of complexity or size.
When a return is made in memory the caller passes a pointer to the memory location as the first parameter (hidden). The callee populates the memory, and returns the pointer. The callee pops the hidden pointer from the stack when returning.
Classes that have a destructor are always passed by reference, even if the parameter is defined to be by value.

But here are others. But the main thing is, this is what a program expects when it's called.

Bob
  #3 (permalink)  
Old 28-Mar-2007, 18:16
ken_yap
Guest
 
Posts: n/a
Default

They are not extensions in firefox, etc, but rather a feature in the KDE/GNOME launcher which allows substitutions to be passed to the invoked program. It's as if you called the program from the CLI with those arguments. I think %u is the name of the logged in user, etc. Unfortunately I can't find a reference to them, this sort of thing is hard to google for if you don't know what terms to use.
  #4 (permalink)  
Old 28-Mar-2007, 18:50
harryc
Guest
 
Posts: n/a
Default

Thanks bobbyn and ken_yap. I had figured that these options passed something to the program they invoked. I appreciate the information. If anyone comes up with a list of what they are/do, that would be great.
  #5 (permalink)  
Old 29-Mar-2007, 12:34
Darkelve
Guest
 
Posts: n/a
Default

Is it possible that the argument for Firefox has something to do with the URL or Html file that it should load instead of the %s ?

It seems to me that these are some kinds of special symbols that take a certain argument.

For example, in the SuSe menu, Kfind takes the option %f ...

And if you press Alt+F2 and type "Kfind Videos" than it looks inside file:///home/Darkelve/Videos . So for Kfind it seems to be a placeholder for a directory name.

When you press Alt+F2 and type "firefox www.userfriendly.org" then it takes that argument and loads that website.

Thunderbird might use %u it to open links from Firefox, or something similar.

It is hard to find any information about this, since I don't know how I can escape special characters (%) in Google...

I *think* these symbols are replaced by whatever input is given to the program. But, I'm not sure of it. It's more like I'm speculating about it.



  #6 (permalink)  
Old 29-Mar-2007, 12:37
harryc
Guest
 
Posts: n/a
Default

Quote:
It is hard to find any information about this, since I don't know how I can escape special characters (%) in Google...
[/b]
Thanks Darkelve. I had the same problem ... that is how to search for % in google.
  #7 (permalink)  
Old 29-Mar-2007, 14:50
bobbyn
Guest
 
Posts: n/a
Default

Well, if you're really interrested, you could download the source for Firefox/Thunderbird. The parameters passed to a program are picked up right at the main() entry point. argc[] contains the number of params and argv[] contains the actual parameters (argv[0] contains the name of the program called). A simple printf statement can show tha actual parameters. I doubt you'd like to go that far, there seems to be no systemwide standard.

Bob
  #8 (permalink)  
Old 29-Mar-2007, 17:05
ken_yap
Guest
 
Posts: n/a
Default

I don't think the code's in Firefox. The substitutions will have already been made by then. It's more likely to be in the launcher.
  #9 (permalink)  
Old 30-Mar-2007, 12:11
bobbyn
Guest
 
Posts: n/a
Default

Ah yes,

But with my method you could display what was subtituted

Bob
  #10 (permalink)  
Old 30-Mar-2007, 14:15
gregsuko
Guest
 
Posts: n/a
Default

Answers for this appear hard to come by, I searched around a bit and found the following that explain bits and pieces.

Maybe it will help give more detail on what to search for anyway. <_<

UbuntuForums
KDE-Forum

Good Luck,
Greg
 
Page 1 of 2 1 2

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2