home *** CD-ROM | disk | FTP | other *** search
- Dear User:
-
- The substance of the computer bulletin board messages below is that
- there are problems in passing far FILE pointers to child processes under
- many otherwise respectable DOS C compilers. So, your `external'
- procedures and functions may work fine, as long as they don't do stream
- I/O, or as long as they only do so from a MEDIUMP (medium model)
- interpreter. The reason for this problem is that most C compilers
- insert their own local file tables into their compiled programs. So, C
- programs check their local file tables before doing I/O, and a child C
- process will fail to discover files opened in a parent process when it
- searches its local file tables.
-
- The solution to this problem, linking the C compiler's libraries into
- the interpreter, and altering the interpreter to trap all calls to
- "external" C procedures and functions and call them locally in
- iosystem(), is illegal. It is illegal for me to compile such an
- interpreter and distribute it, because C compilers' libraries are
- copyright. If you, however, alter assemble.c and/or iosystem.c to do
- this, and abide by the copyright restrictions (your personal use only),
- then it is legal to use your C compilers' libraries directly in your
- Pascal programs.
-
- A future version of the system, expected to be released in mid-to-late
- 1991, will be compatible with other microcomputer versions of Pascal
- (while retaining ISO compatibility with a command-line switch), and it
- will feature a large library of Turbo Pascal (TM) functions implemented
- in C.
-
- Still later versions of the system will run under Windows 3 (TM) and
- will include objects.
-
- ==============================================================================
-
- Date: 10-04-90 (04:31) Number: 13446 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: BJORN KAARIGSTAD Read: 10-06-90 (01:26) HAS Reply/Replies
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- VS> dynamically loads overlays and then uses them as part of the
- VS> parent process, via actual procedure calls and returns.
-
- That is a difficult one. Then you have to develop your own dynamic
- linker, if I understand you correctly.
-
- But if you can use a non-resident solution, you can use spawn and
- pass on a filehandle. You can not return one, becouse when the
- program terminates normaly, it will close all opened files. At
- least that is true with TC.
-
- To pass a file from a parent process to a child you could use
- something like this:
-
- Parent:
-
- #include <io.h>
- #include <fcntl.h>
- #include <process.h>
- #include <stdio.h>
-
- main()
- {
- int handle;
- char chandle[10];
- char *dummy="path";
- if((handle=open("child.c",O_RDONLY))==-1)
- return 1;
- itoa(handle,chandle,10);
- spawnl(P_WAIT,"child.exe",dummy,chandle,NULL);
- close(handle);
- }
- -------------------------------------
- Child:
- -------------------------------------
-
- #include <io.h>
- #include <fcntl.h>
- #include <stdio.h>
-
- main(int argc,char *argv[])
- {
- int handle;
- FILE *in;
- char buf[500];
- handle=atoi(argv[1]);
- fdopen(handle,"rb");
- fread(buf,1,500,in);
- printf("%d\n%s",handle,buf);
- return 0;
- }
-
- -> MegaMail v2.01 #0:
- ---
- ■ QNet 2.04: Interlink: Southboard ■ Lyngdal ■ Norway ■ 043-43880 HST 4 lines
-
- Date: 10-06-90 (21:05) Number: 13566 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: DAVE SIEGEL Read: 10-08-90 (04:28) HAS Reply/Replies
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- VS>Does anyone out there have any words of advice about this?
-
- This can't be done within the ANSI framework. Protected mode systems
- generally require OS intervention to turn data into code (OS/2, for
- example, has a call to create a code segment alias for a data segment).
- Since this stuff is absolutely system specific, ANSI stayed as far away
- from it as possible.
-
- Why not use the linker to set up overlays? Borland, and to a rather
- lesser extent Microsoft, support overlays in a straight-forward fashion.
-
- -dms
- ---
- ■ EZ-Reader 1.21 ■
- ■ QNet 2.04: InterLink: ■ Thunder Road BBS ■ NY, NY ■ (718) 392-8836 HST
-
- Date: 10-08-90 (15:38) Number: 13650 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: ALAN BARCLAY Read: 10-09-90 (13:33) HAS Reply/Replies
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- VS>Although it looks plausible on paper, C has very few ANSI supported
- VS>mechanisms for doing this. "system()" and "spawnl()" work to load
- VS>non-resident child processes, but interesting things like opening a
- VS>file and returning a valid pointer to the parent process or sending
- VS>a file pointer from parent to child and having the child perform
- VS>I/O are completely impossible under, say, DOS, and the idea that
- VS>anyone might want to do this apparently didn't cross the C gurus'
- VS>minds.
-
- The reason that K&R and ANSI didn't do anything like this is because
- swapping & virtual memory is really the concern of the operating system
- and the programmer should never ever need to do this. However DOS doesn't
- and we have to.....
-
- ■ Created on 10-07-90 at 5:03pm
- ---
- ■ DeLuxe² #36sa ■ * UNIX is a Trademark of Bell Laboratories.
- QNet 2.04: Interlink:■Edinburgh Castle ■ Scotland ■ +44 (31) 334 7043
-
- Date: 10-08-90 (00:27) Number: 13658 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: BJORN KAARIGSTAD Read: 10-09-90 (02:26) HAS Reply/Replies
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- Hi Victor,
- I must say that I have not tested on the stream functions, but I
- failto see why they should not work. I my last reply I was passing
- the file handle, and then you have to use the fdopen to make it a
- stream. If however you pass the pointer you MUST use a memorymodel
- that uses FAR pointers. If not you may suffer the failure you
- describe. It is not enough to override on the FILE pointer itself,
- becouse that will not have any effect on the internal pointers in
- the FILE structure. So you end up with a far pointer to the FILE
- struct, but a near pointer to the buffer.
-
- I stress this point couse I suspect you (as I know I would) want to
- have your routines in a .com file and therby uses the tiny model.
-
- Please let me know if you find a useable solution, becouse I'm
- planning a project where I might need something like this.
-
- B.I.Kaarigstad...
-
- -> MegaMail v2.01 #0:
- ---
- ■ QNet 2.04: Interlink: Southboard ■ Lyngdal ■ Norway ■ 043-43880 HST 4 lines
-
- 10-09-90 (21:43) Number: 13780 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: RALPH GOERS Read: 10-10-90 (16:25) HAS Reply/Replies
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- VS>Thanks for your astute reply. I am implementing a somewhat portable
- VS>Pascal interpreter with and EXTERNAL procedure/function declaration
- VS>capability. And, I was hoping to find a reasonable way to call a
- VS>program that passes back a pointer to a requested library procedure/
- VS>function. I assumed that, since it was possible to actually link in
- VS>such a program in OS/2 and even DOS, that other systems might have
- VS>comparable facilities.
-
- If I understand you correctly, we are doing something similar (in MVS).
- They are not called overlays though, since they don't overlay the
- original load module, they are just additionally loaded modules. As
- a matter of fact I think what you are describing is just a DLL in OS/2.
-
- Ralph
- ---
- ■ EZ 1.30 ■
- ■ RNet 1.05L:You Bet Your Ascii ■ Van Nuys ■ CA
-
- Date: 10-10-90 (15:55) Number: 13795 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: DAVID FOX Read: 10-12-90 (02:54) HAS Reply/Replies
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- ══════╡Wednesday, 10 October╞══════
-
- VS┤Thanks very much for your replies. I have just about exhausted the
- │possibilities. The major point is that, in C, the FILE pointer alone
- │does not have enough information to specify everything needed to do
- │i/o. And, my overlays are all large-model, not com-file code. This
-
- I don't follow you here.
-
- I've always assumed that FILE * had an adequate definition for all
- types of stream i/o (fread,fwrite, etc.) and I've not had problems
- with the 'default' definition of the FILE structure in <stdio.h>
- under MSC.
-
- Are you using FILE * stream i/o to load/execute child processes?
-
- If so, why? What's wrong with the spawn.. class of procedures?
- ---
- ■ EZ 1.33 ■ Internal Stack Failure: Plates Broken
- ■ RNet 1.05M:Interlink ■ Higher Powered BBS ■ Sunnyvale CA ■ 408-737-9447
-
- Date: 10-13-90 (04:54) Number: 13878 of 13897 (Echo)
- To: VICTOR SCHNEIDER Refer#: NONE
- From: JOEY LIZZI Read: 10-13-90 (22:01)
- Subj: PORTABLE OVERLAYS IN C Status: PUBLIC MESSAGE
- Conf: C-LANG (70) Read Type: MAIL FOR YOU (+)
-
- ╞═╡I saw your public message on portable overlays, a subject I am
- ╞═╡very interested in right now. Can you tell me where POVR or POVRL
- ╞═╡is available? And, can you pass a file pointer to an overlay and
- ╞═╡have the overlay do i/o on it?
-
- POVR is a shareware program on BBSes. POVRL is the commercial version, I
- think. The overlay should be able to work with current file pointers,
- arrays, etc. Just remember that POVR needs a LINK or LINK-compatible .OBJ
- file linker. These are used in all MS languages and in Turbo C/C++.
-
- ⌡ΘΣÿ
- ---
- ■ EZ 1·33 ■ PC RAID -- Kills Program Bugs DEAD!!
- ■ QNet 2.04: InterLink: Compu-Data ■ Turnersville ■ NJ ■ (609) 232-1245
-