|
|
1.1 root 1: /*
2: * dynlib.c
3: *
1.1.1.2 ! root 4: * Created by Microsoft Corp. 1987
1.1 root 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: /*
22: * NB - This version must be compiled with the -Asnu compiler option.
23: * s => short code pointers
24: * n => near data pointers
25: * u => upon function entry, DS is saved, then made to point to the named
26: * data segment. DS is restored on exit from the function.
27: *
28: */
29:
1.1.1.2 ! root 30: #define INCL_DOSFILEMGR
! 31:
! 32: #include <os2def.h>
! 33: #include <bsedos.h>
1.1 root 34:
35: int _acrtused=0;
36: unsigned id=0; /* process-unique identifier */
37: unsigned far * pcount=0; /* pointer to the shared process count */
38:
1.1.1.2 ! root 39: void APIENTRY /* This routine is called during per-process */
1.1 root 40: init_id(pc) /* initialization to pass the pointer to the */
41: unsigned far * pc; /* shared count and to set the non-shared id. */
42: {
43: pcount = pc;
44: id = *pc;
45: }
46:
1.1.1.2 ! root 47: void APIENTRY /* This routine is called by the process to show */
1.1 root 48: printdata() /* on the screen the current values of the */
49: /* non-shared id and the shared count. */
50: {
51: static char beg[]="I am number ";
52: static char mid[]=". There are ";
53: static char end[]=" processes attached.\r";
54: char c;
1.1.1.2 ! root 55: USHORT Written;
1.1 root 56:
1.1.1.2 ! root 57: DosWrite(1, beg, sizeof(beg)-1, &Written);
1.1 root 58: c = id + '0';
1.1.1.2 ! root 59: DosWrite(1, &c, sizeof(char), &Written);
! 60: DosWrite(1, mid, sizeof(mid)-1, &Written);
1.1 root 61: c = *pcount + '0';
1.1.1.2 ! root 62: DosWrite(1, &c, sizeof(char), &Written);
! 63: DosWrite(1, end, sizeof(end)-1, &Written);
1.1 root 64: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.