|
|
1.1 root 1: /*
2: * dynlib.c
3: *
4: * Created 17 August 1987 by Kevin Ruddell, Microsoft Corp
5: *
6: * Dynamic link library demo module with non-shared data.
7: *
8: */
9:
10: /*
11: * NB - The variable _acrtused must be declared in one of the modules of the
12: * dll. The C compiler generates this symbol as an extern to ensure
13: * that the runtime library startup module crt0 will be pulled in by the
14: * linker. Declaring _acrtused will keep this unwanted code out.
15: *
16: * NB - To be made part of the named data segment, variables at the external
17: * level must be declared static or they must be initialized or both.
18: *
19: */
20:
21: #include <doscalls.h>
22:
23: int _acrtused=0;
24: unsigned id=0; /* process-unique identifier */
25: unsigned far * pcount=0; /* pointer to the shared process count */
26:
27: void far pascal /* This routine is called during per-process */
28: init_id(pc) /* initialization to pass the pointer to the */
29: unsigned far * pc; /* shared count and to set the non-shared id. */
30: {
31: pcount = pc;
32: id = *pc;
33: }
34:
35: void far pascal /* This routine is called by the process to show */
36: printdata() /* on the screen the current values of the */
37: /* non-shared id and the shared count. */
38: {
39: static char beg[]="I am number ";
40: static char mid[]=". There are ";
41: static char end[]=" processes attached.\r";
42: char c;
43: int Written;
44:
45: DOSWRITE(1, beg, sizeof(beg)-1, &Written);
46: c = id + '0';
47: DOSWRITE(1, &c, sizeof(char), &Written);
48: DOSWRITE(1, mid, sizeof(mid)-1, &Written);
49: c = *pcount + '0';
50: DOSWRITE(1, &c, sizeof(char), &Written);
51: DOSWRITE(1, end, sizeof(end)-1, &Written);
52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.