Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!gatech!bloom-beacon!think!ames!ptsfa!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: <28700015@ccvaxa>
Date: Sat, 18-Jul-87 13:30:00 EDT
Article-I.D.: ccvaxa.28700015
Posted: Sat Jul 18 13:30:00 1987
Date-Received: Sun, 19-Jul-87 20:53:02 EDT
References: <22@flmis06.ATT.COM>
Lines: 26
Nf-ID: #R:flmis06.ATT.COM:22:ccvaxa:28700015:000:1159
Nf-From: ccvaxa.UUCP!aglew    Jul 18 12:30:00 1987


/* Written 12:56 pm  Jul 16, 1987 by mikel@flmis06.ATT.COM in ccvaxa:comp.lang.c */
>/* ---------- "Accessing argc & argv from a functi" ---------- */
>I recently ran accross an interresting question.
>
>How does one get at argc and argv (and possibly envp) from a function?
>Without declaring it in main first, and then passing a pointer (global
>or not)! Assume you don't have control over what happens in main. Can
>you still get at the argument vector?
>-- 
>				Mikel Manitius @ AT&T Network Operations
>				mikel@codas.att.com.uucp | attmail!mikel
>/* End of text from ccvaxa:comp.lang.c */

In standard C you cannot get access to argv/argc/envp without doing work
in main().

At McGill I modified crt0 to put argc/argv/envp into globals Argc/Argv/Envp,
as well as passing them to main(). This was useful for a family of debug
and error routines, that told you what command was executing when they
died. der Mouse Parker took this up and may still have it.

I have always thought that perror(str) was silly - sometimes I want
str to be the command name, sometimes the command plus all arguments...

I would like to do the same thing where I now work...