Category : C Source Code
Archive   : CBIBLE.ZIP
Filename : EXECCHLD.C
/* ======================= CHILD ========================= */
/* Must be in file named: CHILD.EXE */
#include
#include
#include
typedef struct TEST_DATA
{
char name[20];
int n;
double x;
} TEST_DATA;
/* CHILD: First argument is program name,
* Second one tells us how child is invoked
* Third argument is an address in the form
* SSSS:0000 (segment:offset). This is the
* address of a data structure allocated in
* the parent. */
static char far *cname = "CHILD";
main(int argc, char **argv, char **envp)
{
char ***p_table;
TEST_DATA far *pdata;
void far *p_s1;
void far *p_s2;
printf("CHILD: received %d arguments\n", argc);
if(argc < 3)
{
printf("not enough arguments\n");
exit(1);
}
printf("CHILD invoked by a %s call.\n",argv[1]);
/* Now print the environment passed to CHILD */
printf("==== CHILD: Environment contains ====\n");
for(p_table = envp; *p_table != NULL; p_table++)
printf("%s\n", *p_table);
/* Read in address of parent's data from argv[2] */
sscanf(argv[2], "%Fp", (void far *)&pdata);
printf("In child: name = %Fs, n = %d, x = %f\n",
pdata->name, pdata->n, pdata->x);
/* Put new values in the data strucute. If CHILD was
* created by a "spawn" function call, this data will
* be available to the parent when child exits.
* Notice that we have to use "movedata" to copy
* "far" data in small or medium model. */
p_s1 = (void far *)cname;
p_s2 = (void far *)pdata->name;
movedata(FP_SEG(p_s1), FP_OFF(p_s1),
FP_SEG(p_s2), FP_OFF(p_s2), 6);
pdata->n = 101;
pdata->x = 999.99;
exit(0);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/