File:  [OS/2 SDKs] / os2sdk / demos / examples / dynlink / far / dynlib.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:25:13 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1987, HEAD
Microsoft OS/2 SDK 12-15-1987

/*
 * dynlib.c
 *
 *   Created 17 August 1987 by Kevin Ruddell, Microsoft Corp
 *
 * Dynamic link library demo module with non-shared data.
 *
 */

/*
 * NB - The variable _acrtused must be declared in one of the modules of the
 *	dll.  The C compiler generates this symbol as an extern to ensure
 *	that the runtime library startup module crt0 will be pulled in by the
 *	linker.  Declaring _acrtused will keep this unwanted code out.
 *
 * NB - To be made part of the named data segment, variables at the external
 *	level must be declared static or they must be initialized or both.
 */

#include <doscalls.h>

int _acrtused=0;
extern unsigned far count;  /* shared count				     */
unsigned id=0;		    /* process-unique identifier		     */

void far pascal 	    /* This routine is called by the process to show */
printdata()		    /* on the screen the current values of the	     */
			    /* non-shared id and the shared count.	     */
{
    static char beg[]="I am number ";
    static char mid[]=".  There are ";
    static char end[]=" processes attached.\r";
    char c;
    int Written;

    DOSWRITE(1, beg, sizeof(beg)-1, &Written);
    c = id + '0';
    DOSWRITE(1, &c, sizeof(char), &Written);
    DOSWRITE(1, mid, sizeof(mid)-1, &Written);
    c = count + '0';
    DOSWRITE(1, &c, sizeof(char), &Written);
    DOSWRITE(1, end, sizeof(end)-1, &Written);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.