Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sri-spam!ames!ptsfa!ihnp4!cuae2!killer!jfh From: jfh@killer.UUCP (The Beach Bum) Newsgroups: comp.lang.c Subject: Re: Accessing argc & argv from a functi Message-ID: <1260@killer.UUCP> Date: Fri, 31-Jul-87 18:34:39 EDT Article-I.D.: killer.1260 Posted: Fri Jul 31 18:34:39 1987 Date-Received: Sun, 2-Aug-87 09:44:46 EDT References: <420@sugar.UUCP> <39@flmis06.ATT.COM> Organization: Big "D" Home for Wayward Hackers Lines: 35 Summary: rewrite /lib/crt0.o or whatever the linker uses to call main. In article <39@flmis06.ATT.COM>, mikel@flmis06.ATT.COM (Mikel Manitius) writes: > > In article <28700015@ccvaxa>, aglew@ccvaxa.UUCP writes: > >> In standard C you cannot get access to argv/argc/envp without doing work > >> in main(). > > Well, I think we may have lost track of the initial problem. > > However I am still looking for a way to get at "argc" and "argv" from > a function when I don't have access to "main". getenv() and putenv() > gets it from somewhere... > > As far as the rest of the above mentioned functions, you will need to > have the args (or at least create your own) first, before you can pass > them on... if one looks at the code for /lib/crt0.o (and friends on unix, god only knows what on Messy-DOS :-) you will see that the run-time start up code saves the address of the environment there. why not just add a few lines to do the dirty work there? (the answer is of course, how many of us have the source to /lib/crt0.o :-(. ms-dos is one up here. my understanding is that most C compilers for ms-dos include the source to the startup routine, which happens to be written in C for the machines i've seen. has anyone written a public domain C startup that also is written in C and only needs alittle munging on? (you are not going to hear me utter the word `disassemble' at any time in this discussions ...) - john -- John F. Haugh II HECI Exploration Co. Inc. UUCP: ...!ihnp4!killer!jfh 11910 Greenville Ave, Suite 600 "Don't Have an Oil Well?" Dallas, TX. 75243 " ... Then Buy One!" (214) 231-0993