Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!oddjob!gargoyle!ihnp4!inuxc!iuvax!pur-ee!uiucdcs!uxc.cso.uiuc.edu!ccvaxa!aglew From: aglew@ccvaxa.UUCP Newsgroups: comp.lang.c Subject: Re: Accessing argc & argv from a functi Message-ID: <28700019@ccvaxa> Date: Tue, 4-Aug-87 13:39:00 EDT Article-I.D.: ccvaxa.28700019 Posted: Tue Aug 4 13:39:00 1987 Date-Received: Sat, 8-Aug-87 02:43:05 EDT References: <22@flmis06.ATT.COM> Lines: 36 Nf-ID: #R:flmis06.ATT.COM:22:ccvaxa:28700019:000:1446 Nf-From: ccvaxa.UUCP!aglew Aug 4 12:39:00 1987 >The solution is to get the source for main() and modify it, or do something >that doesn't involve the arguments, e.g. pass the information you are >looking for in the environment, in a file, etc. You never did get around >to explaining what it is you *really* want to do, or why you are modifying >subroutines' sources but don't have source to main(). I don't know what the original writer was trying to do, but I've often wanted to get argv from deep down inside a program, without modifying main, etc. I write a lot of library routines. Some of them find it necessary to print error messages, or even abort the program. I think that, it in environment where there may be a lot of processes running about, it is nice to know what command died, and even its arguments. I don't like having to tell the users of my routines to arrange to put these somewhere. So, for example, I like to be able to simply plug if( jhgjhgjh ) errorf("my library has a problem\n") and, optionally, get a message like comand arg1 arg2 arg3 my library has a problem from it. Since my home system has shared libraries, I occasionally like plugging things like this into libc, replacing a standard function, without bothering to go and modify main. A special application: I use shared libraries to collect stats on a running system. I like knowing which commands with what arguments are the most extreme cases - eg. who processes the longest string.