From: Paul Crawford <psc@sat.dundee.ac.uk>
To: Frantisek Hanzlik <franta@hanzlici.cz>
Cc: DOSEMU/FreeDOS <linux-msdos@vger.kernel.org>,
Freedos user list <freedos-user@lists.sourceforge.net>
Subject: Re: DOS program recording it's parameters and environment?
Date: Thu, 16 Feb 2012 21:01:53 +0000 [thread overview]
Message-ID: <4F3D6EC1.4050100@sat.dundee.ac.uk> (raw)
In-Reply-To: <4F3D50CF.4000004@hanzlici.cz>
[-- Attachment #1: Type: text/plain, Size: 583 bytes --]
Dear Frantisek,
> compiler v1.9 (http://www.openwatcom.org/) for DOS. And there I knock
> to problem - it seems as this compiler not support construction:
>
> int main(int argc, char *argv[], char *envp[])
I think this 3rd argument may be a MS-specific extension, as most C
programs just have argc & argv in the call to main();
If you change to use the 'environ' variable, that should be pre-defined
(probably in stdlib.h) and should do the same job. Attached is an
example that seems to compile & work under C6 DOS compiler and with gcc
on my Ubuntu 10.04 box.
Regards,
Paul
[-- Attachment #2: dosenv.c --]
[-- Type: text/x-csrc, Size: 470 bytes --]
#include <stdio.h>
#include <stdlib.h>
extern char **environ;
int main(int argc, char *argv[])
{
int ii;
FILE *fp;
char **envp = environ;
fp=fopen("dosenv.txt", "wb");
if(fp != NULL)
{
fprintf(fp, "argc = %d\n", argc);
for(ii=0; ii<argc; ii++)
{
fprintf(fp, "argv[%d] = %s\n", ii, argv[ii]);
}
ii=0;
while(envp != NULL && envp[ii] != NULL)
{
fprintf(fp, "envp[%d] = %s\n", ii, envp[ii]);
ii++;
}
fclose(fp);
}
return 0;
}
next prev parent reply other threads:[~2012-02-16 21:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-18 5:20 DOS program recording it's parameters and environment? Frantisek Hanzlik
[not found] ` <4F16E21B.9030804@gmail.com>
2012-01-18 17:46 ` Frantisek Hanzlik
2012-01-18 17:55 ` Frank Cox
2012-01-18 18:36 ` Frantisek Hanzlik
2012-01-18 19:17 ` Scott
2012-01-27 12:01 ` Paul Crawford
2012-02-16 18:54 ` Frantisek Hanzlik
2012-02-16 21:01 ` Paul Crawford [this message]
2012-02-16 21:34 ` Frantisek Hanzlik
2012-02-17 1:57 ` Samuel Bronson
2012-02-17 22:29 ` Scott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F3D6EC1.4050100@sat.dundee.ac.uk \
--to=psc@sat.dundee.ac.uk \
--cc=franta@hanzlici.cz \
--cc=freedos-user@lists.sourceforge.net \
--cc=linux-msdos@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox